Merge pull request #4539 from Infisical/fix/enableEmailLoginOnChangeEmails

Enable email login on change of emails flows to avoid blocked users
This commit is contained in:
carlosmonastyrski
2025-09-16 15:07:39 -03:00
committed by GitHub
3 changed files with 18 additions and 1 deletions

View File

@@ -294,11 +294,18 @@ export const userServiceFactory = ({
// Delete all user aliases since the email is changing
await userAliasDAL.delete({ userId }, tx);
// Ensure EMAIL auth method is included if not already present
const currentAuthMethods = user.authMethods || [];
const updatedAuthMethods = currentAuthMethods.includes(AuthMethod.EMAIL)
? currentAuthMethods
: [...currentAuthMethods, AuthMethod.EMAIL];
const updatedUser = await userDAL.updateById(
userId,
{
email: newEmail.toLowerCase(),
username: newEmail.toLowerCase()
username: newEmail.toLowerCase(),
authMethods: updatedAuthMethods
},
tx
);