meteorite - After create user on meteor, the session changes to the new user -



meteorite - After create user on meteor, the session changes to the new user -

i'm creating custom "create user" page meteor, , user stored, but, after this, actual session changed new user. i.e. admin user "admin" , when create new user "foo", session changes "foo". i'm overriding account.createuser initial run

this code

template.usuarionew.events 'submit .form': (e) -> e.preventdefault() username = $('#username').val() name = $('#name').val() password = $('#password').val() roles = $('.role:checked') if roles.length == 0 flashmessages.sendwarning 'escoge al menos united nations rol' homecoming user = 'username': username 'password': password 'profile': 'name': name 'roles': [] roles.each (i) -> user.roles.push $(@).val() homecoming accounts.createuser user flashmessages.sendsuccess 'se ha creado united nations usuario' router.go('/') homecoming

and accounts.oncreateuser

accounts.oncreateuser (options, user) -> userproperties = profile: options.profile || {} roles: options.roles || [] user = _.extend user, userproperties if !user.profile.name user.profile.name = user.username if !meteor.users.find().count() user.roles.push 'admin', 'boss', 'specialist' user

this expected behavior if phone call accounts.createuser client. pointed out in the documentation:

on client, function logs in newly created user on successful completion. on server, returns newly created user id.

the way insert user without logging in newly created user initiate creation process server. can method call. in submit callback, replace phone call accounts.createuser user with:

class="lang-coffee prettyprint-override">meteor.call 'insertuser', user

then on server can implement method this:

class="lang-coffee prettyprint-override">meteor.methods 'insertuser': (user) -> check user, match.objectincluding username: string password: string profile: name: string accounts.createuser user

the problem sending user's password server, reasonable if using ssl. , then, may not great idea...

if don't want transmit password, docs point out, can create user using illustration above, want replace password email, , phone call sendenrollmentemail so:

class="lang-coffee prettyprint-override">meteor.methods 'insertuser': (user) -> check user, match.objectincluding username: string email: string profile: name: string userid = accounts.createuser user accounts.sendenrollmentemail userid

then need create route on client which, when requested, makes phone call resetpassword appropriate token , new password. doing more work both , user it's secure implementation meets requirements.

meteor meteorite

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -