mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🔑 fix(AuthService): properly handle reading and deletion of password reset token (#3697)
This commit is contained in:
parent
cebb3751c1
commit
d4c0f7267a
1 changed files with 2 additions and 3 deletions
|
|
@ -280,9 +280,8 @@ const requestPasswordReset = async (req) => {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const resetPassword = async (userId, token, password) => {
|
const resetPassword = async (userId, token, password) => {
|
||||||
let passwordResetToken = await createToken({
|
let passwordResetToken = await findToken({
|
||||||
userId,
|
userId,
|
||||||
expiresIn: 900,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!passwordResetToken) {
|
if (!passwordResetToken) {
|
||||||
|
|
@ -311,7 +310,7 @@ const resetPassword = async (userId, token, password) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await passwordResetToken.deleteOne();
|
await deleteTokens({ token: passwordResetToken.token });
|
||||||
logger.info(`[resetPassword] Password reset successful. [Email: ${user.email}]`);
|
logger.info(`[resetPassword] Password reset successful. [Email: ${user.email}]`);
|
||||||
return { message: 'Password reset was successful' };
|
return { message: 'Password reset was successful' };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue