Record local email for social users where possible (#14029)

* fix(auth): record local email for social users where possible

* fix(auth): Apple emails are junk, prefer Google

* fix(auth): correct placement of logic to save local email

* fix(auth): run full function in both workflows to avoid conflicts

Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
Sabe Jones
2022-06-03 15:06:40 -05:00
committed by GitHub
parent afc7b1218a
commit 341517083e
3 changed files with 33 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ import {
hasBackupAuth,
loginSocial,
registerLocal,
socialEmailToLocal,
} from '../../libs/auth';
import { verifyUsername } from '../../libs/user/validation';
@@ -478,6 +479,7 @@ api.resetPasswordSetNewOne = {
// set new password and make sure it's using bcrypt for hashing
await passwordUtils.convertToBcrypt(user, String(newPassword));
user.auth.local.passwordResetCode = undefined; // Reset saved password reset code
if (!user.auth.local.email) user.auth.local.email = await socialEmailToLocal(user);
await user.save();
return res.respond(200, {}, res.t('passwordChangeSuccess'));