Skip to content

Commit d1583a5

Browse files
fnetXlunny
authored and
Otto Richter
committed
CB/bp: Fix error on account activation with wrong passwd (go-gitea#22609)
On activating local accounts, the error message didn't differentiate between using a wrong or expired token, or a wrong password. The result could already be obtained from the behaviour (different screens were presented), but the error message was misleading and lead to confusion for new users on Codeberg with Forgejo. Now, entering a wrong password for a valid token prints a different error message. The problem was introduced in 0f14f69. Co-authored-by: Lunny Xiao <[email protected]>
1 parent 95b64b7 commit d1583a5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

options/locales/gitea_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ email_not_associate = The email address is not associated with any account.
321321
send_reset_mail = Send Account Recovery Email
322322
reset_password = Account Recovery
323323
invalid_code = Your confirmation code is invalid or has expired.
324+
invalid_password = Your password does not match the password that was used to create the account.
324325
reset_password_helper = Recover Account
325326
reset_password_wrong_user = You are signed in as %s, but the account recovery link is for %s
326327
password_too_short = Password length cannot be less than %d characters.

routers/web/auth/auth.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ func Activate(ctx *context.Context) {
687687
user := user_model.VerifyUserActiveCode(code)
688688
// if code is wrong
689689
if user == nil {
690-
ctx.Data["IsActivateFailed"] = true
690+
ctx.Data["IsCodeInvalid"] = true
691691
ctx.HTML(http.StatusOK, TplActivate)
692692
return
693693
}
@@ -714,7 +714,7 @@ func ActivatePost(ctx *context.Context) {
714714
user := user_model.VerifyUserActiveCode(code)
715715
// if code is wrong
716716
if user == nil {
717-
ctx.Data["IsActivateFailed"] = true
717+
ctx.Data["IsCodeInvalid"] = true
718718
ctx.HTML(http.StatusOK, TplActivate)
719719
return
720720
}
@@ -729,7 +729,7 @@ func ActivatePost(ctx *context.Context) {
729729
return
730730
}
731731
if !user.ValidatePassword(password) {
732-
ctx.Data["IsActivateFailed"] = true
732+
ctx.Data["IsPasswordInvalid"] = true
733733
ctx.HTML(http.StatusOK, TplActivate)
734734
return
735735
}

templates/user/auth/activate.tmpl

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
<input id="code" name="code" type="hidden" value="{{.Code}}">
3131
{{else if .IsSendRegisterMail}}
3232
<p>{{.locale.Tr "auth.confirmation_mail_sent_prompt" (.Email|Escape) .ActiveCodeLives | Str2html}}</p>
33-
{{else if .IsActivateFailed}}
33+
{{else if .IsCodeInvalid}}
3434
<p>{{.locale.Tr "auth.invalid_code"}}</p>
35+
{{else if .IsPasswordInvalid}}
36+
<p>{{.locale.Tr "auth.invalid_password"}}</p>
3537
{{else if .ManualActivationOnly}}
3638
<p class="center">{{.locale.Tr "auth.manual_activation_only"}}</p>
3739
{{else}}

0 commit comments

Comments
 (0)