Add `options.preserveAccessTokens`
Add an option to preserve access tokens when email/password is changed.
This commit is contained in:
parent
0bb7cd67ec
commit
2b7b0e1cc1
|
@ -1385,6 +1385,8 @@ module.exports = function(User) {
|
|||
|
||||
if (!newEmail && !newPassword) return next();
|
||||
|
||||
if (ctx.options.preserveAccessTokens) return next();
|
||||
|
||||
var userIdsToExpire = ctx.hookState.originalUserData.filter(function(u) {
|
||||
return (newEmail && u.email !== newEmail) ||
|
||||
(newPassword && u.password !== newPassword);
|
||||
|
|
|
@ -2755,6 +2755,17 @@ describe('User', function() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('keeps sessions sessions when preserveAccessTokens is passed in options', function(done) {
|
||||
user.updateAttributes(
|
||||
{email: 'invalidateAccessTokens@example.com'},
|
||||
{preserveAccessTokens: true},
|
||||
function(err, userInstance) {
|
||||
if (err) return done(err);
|
||||
assertPreservedTokens(done);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves other users\' sessions if their email is untouched', function(done) {
|
||||
var user1, user2, user3;
|
||||
async.series([
|
||||
|
|
Loading…
Reference in New Issue