Skip to content

Commit b3c5e83

Browse files
committed
Clear reset password token after reset password. _perishable_token is not a parse field, cannot clear it through rest. Update it separately. #951
1 parent 53e152e commit b3c5e83

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Controllers/UserController.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,15 @@ export class UserController extends AdaptableController {
168168
updatePassword(username, token, password, config) {
169169
return this.checkResetTokenValidity(username, token).then((user) => {
170170
return updateUserPassword(user._id, password, this.config);
171-
});
171+
}).then(() => {
172+
// clear reset password token
173+
return this.config.database.adaptiveCollection('_User').then(function (collection) {
174+
// Need direct database access because verification token is not a parse field
175+
return collection.findOneAndUpdate({ username: username },// query
176+
{ $set: { _perishable_token: null } } // update
177+
);
178+
});
179+
});
172180
}
173181

174182
defaultVerificationEmail({link, user, appName, }) {
@@ -195,8 +203,7 @@ export class UserController extends AdaptableController {
195203
// Mark this private
196204
function updateUserPassword(userId, password, config) {
197205
return rest.update(config, Auth.master(config), '_User', userId, {
198-
password: password,
199-
_perishable_token: null
206+
password: password
200207
});
201208
}
202209

0 commit comments

Comments
 (0)