admin管理员组

文章数量:1180475

Accounts.setPassword(userId, password);

Before Meteor v1.0.2, the user was not logout when calling this function.

Since v1.0.2, I quote from .md, "Expire a user's password reset and login tokens in all circumstances when their password is changed".

I don't know the reason of this change,but the fact is that function above logout the user.

Is there a way, with v1.0.2, to change a user password without logout the user?

If not, how do I downgrade the package account-base so the behaviour is like before?

Thanks.

Accounts.setPassword(userId, password);

Before Meteor v1.0.2, the user was not logout when calling this function.

Since v1.0.2, I quote from https://github.com/meteor/meteor/blob/devel/History.md, "Expire a user's password reset and login tokens in all circumstances when their password is changed".

I don't know the reason of this change,but the fact is that function above logout the user.

Is there a way, with v1.0.2, to change a user password without logout the user?

If not, how do I downgrade the package account-base so the behaviour is like before?

Thanks.

Share Improve this question edited Dec 29, 2014 at 17:57 user2409399 asked Dec 29, 2014 at 17:28 user2409399user2409399 2673 silver badges16 bronze badges 1
  • atmospherejs.com/i/installing – sdooo Commented Dec 29, 2014 at 19:17
Add a comment  | 

3 Answers 3

Reset to default 21
Accounts.setPassword(userId, password, options)

This method now supports options parameter that includes options.logout option which could be used to prevent the current user's logout.

You could use Accounts.changePassword (docs) to change the password instead, this will not affect the user's existing tokens (as from) https://github.com/meteor/meteor/blob/devel/packages/accounts-password/password_server.js#L299-L302

If you want to do this from the server without knowing the existing password you would have to fork the accounts-password package and remove this line: https://github.com/meteor/meteor/blob/devel/packages/accounts-password/password_server.js#L338 and add this package into the /packages directory of your app

If you want to downgrade your package (so long as the version you're using of meteor supports it):

meteor remove accounts-password
meteor add [email protected]

The above answer is correct and here's the exact copy-paste code in case you're struggling:

Accounts.setPassword(userId, password, {logout: false});

Note: make sure you are doing this call server side.

本文标签: javascriptMeteor change a user password WITHOUT logoutStack Overflow