From 418f27f586c628b2728b3f7fce883ccbc5c5c3bf Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Wed, 4 Oct 2023 16:35:50 +0800 Subject: [PATCH] fix convert to email login does not change source field in user table --- packages/api/src/routers/auth/auth_router.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index b0f6d821e..a2efc46c2 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -685,17 +685,14 @@ export function authRouter() { ) } - // check if email needs to be updated - const updateEmail = claims.email && claims.email !== user.email - const hashedPassword = await hashPassword(password) const updated = await AppDataSource.transaction( async (entityManager) => { await setClaims(entityManager, user.id) return entityManager.getRepository(User).update(user.id, { password: hashedPassword, - email: updateEmail ? claims.email : undefined, - source: updateEmail ? RegistrationType.Email : undefined, + email: claims.email ?? undefined, // update email address if it was provided + source: RegistrationType.Email, // reset password will always be email }) } )