Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit 27009f2

Browse files
authored
Too many attempts message (#745)
1 parent ddd634d commit 27009f2

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

cmd/server/assets/login/login.html

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
flash.clear();
139139
flash.error('Unsupported 2nd factor authentication type.');
140140
}
141+
} else if (error.code == 'auth/too-many-requests'){
142+
flash.clear();
143+
flash.error(err.message);
144+
$submit.prop('disabled', false);
141145
} else {
142146
flash.clear();
143147
flash.error("Sign-in failed. Please try again.");

internal/firebase/error.go

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var (
2525
ErrCredentialTooOld = &ErrorDetails{Err: "CREDENTIAL_TOO_OLD_LOGIN_AGAIN"}
2626
ErrTokenExpired = &ErrorDetails{Err: "TOKEN_EXPIRED"}
2727
ErrInvalidToken = &ErrorDetails{Err: "INVALID_ID_TOKEN"}
28+
ErrTooManyAttempts = &ErrorDetails{Err: "TOO_MANY_ATTEMPTS_TRY_LATER"}
2829
)
2930

3031
var _ error = (*ErrorDetails)(nil)

pkg/controller/login/reset_password.go

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ func (c *Controller) HandleSubmitResetPassword() http.Handler {
5757
}
5858

5959
if err := c.firebaseInternal.SendPasswordResetEmail(ctx, strings.TrimSpace(form.Email)); err != nil {
60+
if errors.Is(err, firebase.ErrTooManyAttempts) {
61+
flash.Error("Too many attempts have been made. Please wait and try again later.")
62+
c.renderResetPassword(ctx, w, flash)
63+
return
64+
}
65+
6066
// Treat not-found like success so we don't leak details.
6167
if !errors.Is(err, firebase.ErrEmailNotFound) {
6268
flash.Error("Password reset failed.")

0 commit comments

Comments
 (0)