Closed sasaar closed 1 month ago
Hi @sasaar , thanks for opening this issue.
Unfortunately Cognito returns a NotAuthorizedException
error both when the credentials are incorrect and when the attempts have been exceeded. Because of that, we don't have a reliable way of differentiating them either, since the "Password attempts exceeded"
string you see is also directly coming from the service and might change without notice.
I'll tag this as a feature request and we'll discuss if there's any alternative we can offer. Thanks!
Thanks for the prompt reply.
We've released version 1.1.7 that now lets you use the errorMap(_:)
view modifier to provide a new message only for the error you wish to overwrite; if you return nil
then the Authenticator will handle it as usual.
For example, this would achieve what you wish:
Authenticator { _ in
// ....
}
.errorMap { error in
// Return custom message when password attempts are exceeded
if case .notAuthorized(let description, _, _) = error, description == "Password attempts exceeded" {
return .error(message: "[Your custom message]")
}
// Let the Authenticator handle all remaining errors
return nil
}
However, as I said earlier, keep in mind that the description string is coming directly from the Cognito service and that it might change.
Many thanks. We will try this (version 1.1.7) asap.
Hi @sasaar, we've decided to handle this particular scenario within the Authenticator. It's been released in version 1.1.8.
You can still use the errorMap(_:)
function to provide custom error messages, but now the Authenticator should already show a different error message when the passwords attempts are exceeded.
I'm closing this feature request as completed. Feel free to reopen it or create another issue if something's not working as expected. Thanks!
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Description: This is more feature request than bug, but after user has entered wrong credentials on login several times and then provides correct credentials, localised message for .notAuthorized is returned:
AuthenticatorBaseState still seems to know the exact reason:
Would it be possible to get own localized message for login error when password attempts are exceeded?