fix convert to email login does not change source field in user table

This commit is contained in:
Hongbo Wu
2023-10-04 16:35:50 +08:00
parent c41363b51c
commit 418f27f586

View File

@ -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
})
}
)