Skip to content
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

Handle API response for mobile OTP code incorrect. #371

Merged
merged 3 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ public boolean isMultifactorTokenInvalid() {

/// When MFA code sent is invalid or expired
public boolean isMultifactorCodeInvalid() {
return "a0.mfa_invalid_code".equals(code) || "invalid_grant".equals(code) && "Invalid otp_code.".equals(description);
return "a0.mfa_invalid_code".equals(code)
|| "invalid_grant".equals(code) && "Invalid otp_code.".equals(description)
|| "invalid_grant".equals(code) && "Wrong phone number or verification code.".equals(description)
|| "invalid_grant".equals(code) && "Wrong email or verification code.".equals(description);
}

/// When password used for SignUp does not match connection's strength requirements.
Expand Down Expand Up @@ -238,4 +241,4 @@ public boolean isLoginRequired() {
return "login_required".equals(code);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ public void shouldHaveInvalidMultifactorCodeOnOIDCMode() {
assertThat(ex.isMultifactorCodeInvalid(), is(true));
}

@Test
public void shouldHaveInvalidMultifactorCodePhoneOTP() {
values.put(ERROR_KEY, "invalid_grant");
values.put(ERROR_DESCRIPTION_KEY, "Wrong phone number or verification code.");
AuthenticationException ex = new AuthenticationException(values);
assertThat(ex.isMultifactorCodeInvalid(), is(true));
}

@Test
public void shouldHaveInvalidMultifactorCodeEmailOTP() {
values.put(ERROR_KEY, "invalid_grant");
values.put(ERROR_DESCRIPTION_KEY, "Wrong email or verification code.");
AuthenticationException ex = new AuthenticationException(values);
assertThat(ex.isMultifactorCodeInvalid(), is(true));
}

@Test
public void shouldHaveInvalidMultifactorCode() {
values.put(CODE_KEY, "a0.mfa_invalid_code");
Expand Down Expand Up @@ -323,4 +339,4 @@ public void shouldHaveMissingBrowserApp() {
assertThat(ex.isBrowserAppNotAvailable(), is(true));
}

}
}