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
3 Answers
Reset to default 21Accounts.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
版权声明:本文标题:javascript - Meteor: change a user password WITHOUT logout? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738140407a2065665.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论