Skip to content

Commit 95d9fbd

Browse files
fnetXlunny
andauthored
Fix error on account activation with wrong passwd (#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 74466eb commit 95d9fbd

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Diff for: options/locale/locale_en-US.ini

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

Diff for: routers/web/auth/auth.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ func Activate(ctx *context.Context) {
633633
user := user_model.VerifyUserActiveCode(code)
634634
// if code is wrong
635635
if user == nil {
636-
ctx.Data["IsActivateFailed"] = true
636+
ctx.Data["IsCodeInvalid"] = true
637637
ctx.HTML(http.StatusOK, TplActivate)
638638
return
639639
}
@@ -660,7 +660,7 @@ func ActivatePost(ctx *context.Context) {
660660
user := user_model.VerifyUserActiveCode(code)
661661
// if code is wrong
662662
if user == nil {
663-
ctx.Data["IsActivateFailed"] = true
663+
ctx.Data["IsCodeInvalid"] = true
664664
ctx.HTML(http.StatusOK, TplActivate)
665665
return
666666
}
@@ -675,7 +675,7 @@ func ActivatePost(ctx *context.Context) {
675675
return
676676
}
677677
if !user.ValidatePassword(password) {
678-
ctx.Data["IsActivateFailed"] = true
678+
ctx.Data["IsPasswordInvalid"] = true
679679
ctx.HTML(http.StatusOK, TplActivate)
680680
return
681681
}

Diff for: 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)