fix: incorrect error messsage for invalid login credentials (#10117)
* fir ErrorCode enum * update incorrect credentails message
This commit is contained in:
1 parent
c1a9f4b656
commit
352a9e2fec
5 files changed
+9
-9
No files matched your search
@@ -1,5 +1,5 @@
|
||||
export enum ErrorCode {
|
||||
IncorrectUsernamePassword = "incorrect-username-password",
|
||||
IncorrectEmailPassword = "incorrect-email-password",
|
||||
UserNotFound = "user-not-found",
|
||||
IncorrectPassword = "incorrect-password",
|
||||
UserMissingPassword = "missing-password",
|
||||
|
||||
@@ -100,7 +100,7 @@ const providers: Provider[] = [
|
||||
|
||||
// Don't leak information about it being username or password that is invalid
|
||||
if (!user) {
|
||||
throw new Error(ErrorCode.IncorrectUsernamePassword);
|
||||
throw new Error(ErrorCode.IncorrectEmailPassword);
|
||||
}
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
@@ -112,16 +112,16 @@ const providers: Provider[] = [
|
||||
}
|
||||
|
||||
if (!user.password && user.identityProvider !== IdentityProvider.CAL && !credentials.totpCode) {
|
||||
throw new Error(ErrorCode.IncorrectUsernamePassword);
|
||||
throw new Error(ErrorCode.IncorrectEmailPassword);
|
||||
}
|
||||
|
||||
if (user.password || !credentials.totpCode) {
|
||||
if (!user.password) {
|
||||
throw new Error(ErrorCode.IncorrectUsernamePassword);
|
||||
throw new Error(ErrorCode.IncorrectEmailPassword);
|
||||
}
|
||||
const isCorrectPassword = await verifyPassword(credentials.password, user.password);
|
||||
if (!isCorrectPassword) {
|
||||
throw new Error(ErrorCode.IncorrectUsernamePassword);
|
||||
throw new Error(ErrorCode.IncorrectEmailPassword);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user