Scheduling infrastructure for absolutely everyone.
fix: simplify credentials provider authorization flow (#25563)
Alex van Andel63d1361a7a99
diff --git a/packages/features/auth/lib/next-auth-options.ts b/packages/features/auth/lib/next-auth-options.tsindex 5e317ccf196..e4ee24a9f76 100644--- a/packages/features/auth/lib/next-auth-options.ts+++ b/packages/features/auth/lib/next-auth-options.ts@@ -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) {