Skip to content

Commit

Permalink
review: move the execution time of the validateUserCredentials method…
Browse files Browse the repository at this point in the history
… before assigning true to the session.passwordValid
  • Loading branch information
YunhwanJeong committed Oct 9, 2024
1 parent 33288d2 commit 3a52f2f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/login/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ async function challengeUsernamePassword(session: LoginSession, username: string
);
}

const { success, errorMessage } = await services.user.validateUserCredentials(user, password, ctx);
if (!success && errorMessage) {
throw new A12nLoginChallengeError(
session,
errorMessage,
'username-password',
true,
);
}

session.principalId = user.id;
session.passwordValid = true;
session.dirty = true;
Expand All @@ -251,16 +261,6 @@ async function challengeUsernamePassword(session: LoginSession, username: string
);
}

const { success, errorMessage } = await services.user.validateUserCredentials(user, password, ctx);
if (!success && errorMessage) {
throw new A12nLoginChallengeError(
session,
errorMessage,
'username-password',
true,
);
}

return user;
}

Expand Down

0 comments on commit 3a52f2f

Please sign in to comment.