mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: clear reset tokens on successful login
This commit is contained in:
@@ -360,6 +360,7 @@ authenticationController.onSuccessfulLogin = async function (req, uid) {
|
||||
await meta.blacklist.test(req.ip);
|
||||
await user.logIP(uid, req.ip);
|
||||
await user.bans.unbanIfExpired([uid]);
|
||||
await user.reset.cleanByUid(uid);
|
||||
|
||||
req.session.meta = {};
|
||||
|
||||
|
||||
@@ -556,4 +556,11 @@ describe('authentication', () => {
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should clear all reset tokens upon successful login', async () => {
|
||||
const code = await user.reset.generate(regularUid);
|
||||
await loginUserPromisified('regular', 'regularpwd');
|
||||
const valid = await user.reset.validate(code);
|
||||
assert.strictEqual(valid, false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user