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

Add AuthenticationException.isTooManyAttempts error #615

Merged
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 @@ -194,6 +194,10 @@ public class AuthenticationException : Auth0Exception {
public val isIdTokenValidationError: Boolean
get() = cause is TokenValidationException

/// When the user is blocked due to too many attempts to log in
public val isTooManyAttempts: Boolean
get() = "too_many_attempts" == code

internal companion object {
internal const val ERROR_VALUE_AUTHENTICATION_CANCELED = "a0.authentication_canceled"
private const val ERROR_KEY = "error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@ public class AuthenticationExceptionTest {
MatcherAssert.assertThat(ex.isRefreshTokenDeleted, CoreMatchers.`is`(true))
}

@Test
public fun shouldHaveTooManyAttempts() {
values[CODE_KEY] = "too_many_attempts"
val ex = AuthenticationException(
values
)
MatcherAssert.assertThat(ex.isTooManyAttempts, CoreMatchers.`is`(true))
}

private companion object {
private const val PASSWORD_STRENGTH_ERROR_RESPONSE =
"src/test/resources/password_strength_error.json"
Expand All @@ -493,4 +502,4 @@ public class AuthenticationExceptionTest {
private const val ERROR_DESCRIPTION_KEY = "error_description"
private const val DESCRIPTION_KEY = "description"
}
}
}