Skip to content

Commit 5b0c28e

Browse files
authored
Merge pull request #112 from harshithpabbati/signup-msg
fix: return user already exists message on signing up more than once …
2 parents 485b5c9 + ac0ac5e commit 5b0c28e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

api/signup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ func (a *API) Signup(w http.ResponseWriter, r *http.Request) error {
8888
mailer := a.Mailer(ctx)
8989
referrer := a.getReferrer(r)
9090
if terr = sendConfirmation(tx, user, mailer, config.SMTP.MaxFrequency, referrer); terr != nil {
91+
if errors.Is(terr, MaxFrequencyLimitError) {
92+
now := time.Now()
93+
left := user.ConfirmationSentAt.Add(config.SMTP.MaxFrequency).Add(-now)
94+
return tooManyRequestsError(fmt.Sprintf("For security purposes, you can only request this after %d seconds.", left))
95+
}
9196
return internalServerError("Error sending confirmation mail").WithInternalError(terr)
9297
}
9398
}

0 commit comments

Comments
 (0)