Return password reset link on reset request route

This commit is contained in:
Johannes Zellner
2021-09-16 14:34:56 +02:00
parent ecd35bd08d
commit 074ce574dd
3 changed files with 11 additions and 7 deletions

View File

@@ -550,13 +550,17 @@ async function sendPasswordResetByIdentifier(identifier, auditSource) {
const user = identifier.indexOf('@') === -1 ? await getByUsername(identifier.toLowerCase()) : await getByEmail(identifier.toLowerCase());
if (!user) throw new BoxError(BoxError.NOT_FOUND, 'User not found');
let resetToken = hat(256), resetTokenCreationTime = new Date();
const resetToken = hat(256);
const resetTokenCreationTime = new Date();
user.resetToken = resetToken;
user.resetTokenCreationTime = resetTokenCreationTime;
await update(user, { resetToken, resetTokenCreationTime }, auditSource);
await mailer.passwordReset(user);
const resetLink = `${settings.dashboardOrigin()}/login.html?resetToken=${user.resetToken}`;
await mailer.passwordReset(user, resetLink);
return resetLink;
}
async function notifyLoginLocation(user, ip, userAgent, auditSource) {