fix: simplify credentials provider authorization flow (#25563)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Alex van Andel
2025-12-03 09:21:20 +00:00
committed by GitHub
co-authored by Devin AI
parent cbcd769f88
commit 63d1361a7a
@@ -169,21 +169,15 @@ const providers: Provider[] = [
identifier: hashEmail(user.email),
});
if (!user.password?.hash && user.identityProvider !== IdentityProvider.CAL && !credentials.totpCode) {
throw new Error(ErrorCode.IncorrectEmailPassword);
}
if (!user.password?.hash && user.identityProvider == IdentityProvider.CAL) {
// Users without a password must use their identity provider (Google/SAML) to login
if (!user.password?.hash) {
throw new Error(ErrorCode.IncorrectEmailPassword);
}
if (user.password?.hash && !credentials.totpCode) {
if (!user.password?.hash) {
throw new Error(ErrorCode.IncorrectEmailPassword);
}
const isCorrectPassword = await verifyPassword(credentials.password, user.password.hash);
if (!isCorrectPassword) {
throw new Error(ErrorCode.IncorrectEmailPassword);
}
// Always verify password for users who have one
const isCorrectPassword = await verifyPassword(credentials.password, user.password.hash);
if (!isCorrectPassword) {
throw new Error(ErrorCode.IncorrectEmailPassword);
}
if (user.twoFactorEnabled && credentials.backupCode) {