-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OTP form issues #7
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,23 +115,18 @@ public void action(AuthenticationFlowContext context) { | |
context.success(); | ||
} | ||
} else { | ||
// invalid | ||
AuthenticationExecutionModel execution = context.getExecution(); | ||
if (execution.isRequired()) { | ||
context.failureChallenge(AuthenticationFlowError.INVALID_CREDENTIALS, | ||
context.form().setAttribute("realm", context.getRealm()) | ||
.setError("emailTOTPCodeInvalid").createForm(TOTP_FORM)); | ||
} else if (execution.isConditional() || execution.isAlternative()) { | ||
if (remainingAttempts > 0) { | ||
// decrement the remaining attempts | ||
authSession.setAuthNote(AUTH_NOTE_REMAINING_RETRIES, Integer.toString(remainingAttempts - 1)); | ||
// display the error message | ||
// Code is invalid | ||
remainingAttempts--; | ||
authSession.setAuthNote(AUTH_NOTE_REMAINING_RETRIES, Integer.toString(remainingAttempts)); | ||
Comment on lines
+119
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this inside the the condition. |
||
|
||
if (remainingAttempts > 0) { | ||
// Inform user of the remaining attempts | ||
context.failureChallenge(AuthenticationFlowError.INVALID_CREDENTIALS, | ||
context.form().setAttribute("realm", context.getRealm()) | ||
.setError("emailTOTPCodeInvalid", remainingAttemptsStr).createForm(TOTP_FORM)); | ||
} else { | ||
context.attempted(); | ||
} | ||
context.form().setAttribute("realm", context.getRealm()) | ||
.setError("emailTOTPCodeInvalid", Integer.toString(remainingAttempts)).createForm(TOTP_FORM)); | ||
} else { | ||
// Reset login | ||
context.resetFlow(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an error here if you can. If you can't, I may take a look at that later. |
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert these changes. (The button probably should just be removed, but that could be a breaking change for some.) We could add a resend button, but to get that working properly for everyone, it would still be removing the "back to login", and adding a new button with some logic in src/main/java/com/weare5stones/keycloak/authenticators/emailotp/EmailOTPAuthenticator.java |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be 2.0.1, since it's just fixing the attempt logic when it's set as required.