Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on account activation with wrong passwd #22609

Merged
merged 3 commits into from Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Expand Up @@ -322,6 +322,7 @@ email_not_associate = The email address is not associated with any account.
send_reset_mail = Send Account Recovery Email
reset_password = Account Recovery
invalid_code = Your confirmation code is invalid or has expired.
invalid_password = Your password does not match the password that was used to create the account.
reset_password_helper = Recover Account
reset_password_wrong_user = You are signed in as %s, but the account recovery link is for %s
password_too_short = Password length cannot be less than %d characters.
Expand Down
6 changes: 3 additions & 3 deletions routers/web/auth/auth.go
Expand Up @@ -633,7 +633,7 @@ func Activate(ctx *context.Context) {
user := user_model.VerifyUserActiveCode(code)
// if code is wrong
if user == nil {
ctx.Data["IsActivateFailed"] = true
ctx.Data["IsCodeInvalid"] = true
ctx.HTML(http.StatusOK, TplActivate)
return
}
Expand All @@ -660,7 +660,7 @@ func ActivatePost(ctx *context.Context) {
user := user_model.VerifyUserActiveCode(code)
// if code is wrong
if user == nil {
ctx.Data["IsActivateFailed"] = true
ctx.Data["IsCodeInvalid"] = true
ctx.HTML(http.StatusOK, TplActivate)
return
}
Expand All @@ -675,7 +675,7 @@ func ActivatePost(ctx *context.Context) {
return
}
if !user.ValidatePassword(password) {
ctx.Data["IsActivateFailed"] = true
ctx.Data["IsPasswordInvalid"] = true
ctx.HTML(http.StatusOK, TplActivate)
return
}
Expand Down
4 changes: 3 additions & 1 deletion templates/user/auth/activate.tmpl
Expand Up @@ -30,8 +30,10 @@
<input id="code" name="code" type="hidden" value="{{.Code}}">
{{else if .IsSendRegisterMail}}
<p>{{.locale.Tr "auth.confirmation_mail_sent_prompt" (.Email|Escape) .ActiveCodeLives | Str2html}}</p>
{{else if .IsActivateFailed}}
{{else if .IsCodeInvalid}}
<p>{{.locale.Tr "auth.invalid_code"}}</p>
{{else if .IsPasswordInvalid}}
<p>{{.locale.Tr "auth.invalid_password"}}</p>
{{else if .ManualActivationOnly}}
<p class="center">{{.locale.Tr "auth.manual_activation_only"}}</p>
{{else}}
Expand Down