Skip to content

Commit

Permalink
Merge pull request #494 from auth0/use-err-description
Browse files Browse the repository at this point in the history
Improve access_denied error handling by using the description
  • Loading branch information
lbalmaceda authored Jun 30, 2021
2 parents 79743a3 + cde91d0 commit 5487ddc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ internal class OAuthManager(
ERROR_VALUE_ACCESS_DENIED.equals(errorValue, ignoreCase = true) -> {
throw AuthenticationException(
ERROR_VALUE_ACCESS_DENIED,
"Permissions were not granted. Try again."
errorDescription ?: "Permissions were not granted. Try again."
)
}
ERROR_VALUE_UNAUTHORIZED.equals(errorValue, ignoreCase = true) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,36 @@ public class WebAuthProviderTest {
)
}

@Test
public fun shouldFailToResumeLoginWithIntentWithAccessDeniedAndDescription() {
login(account)
.withState("1234567890")
.start(activity, callback)
val intent = createAuthIntent(
createHash(
null,
"aToken",
null,
"urlType",
1111L,
"1234567890",
"access_denied",
"email is already associated with another account",
null
)
)
Assert.assertTrue(resume(intent))
verify(callback).onFailure(authExceptionCaptor.capture())
assertThat(
authExceptionCaptor.firstValue, `is`(notNullValue())
)
assertThat(authExceptionCaptor.firstValue.getCode(), `is`("access_denied"))
assertThat(
authExceptionCaptor.firstValue.getDescription(),
`is`("email is already associated with another account")
)
}

@Test
public fun shouldFailToResumeLoginWithIntentWithRuleError() {
login(account)
Expand Down

0 comments on commit 5487ddc

Please sign in to comment.