mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-12 07:42:08 +01:00
d4fc0d2c5a
During registration, one may be required to give their email address, to be verified and activated later. However, if one makes a mistake, a typo, they may end up with an account that cannot be activated due to having a wrong email address. They can still log in, but not change the email address, thus, no way to activate it without help from an administrator. To remedy this issue, lets allow changing the email address for logged in, but not activated users. This fixes gitea#17785. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commitaaaece28e4
) (cherry picked from commit639dafabec
) (cherry picked from commitd699c12ceb
) [GITEA] Allow changing the email address before activation (squash) cache is always active This needs to be revisited because the MailResendLimit is not enforced and turns out to not be tested. Seee7cb8da2a8
* Always enable caches (#28527) (cherry picked from commit43ded8ee30
) Rate limit pre-activation email change separately Changing the email address before any email address is activated should be subject to a different rate limit than the normal activation email resending. If there's only one rate limit for both, then if a newly signed up quickly discovers they gave a wrong email address, they'd have to wait three minutes to change it. With the two separate limits, they don't - but they'll have to wait three minutes before they can change the email address again. The downside of this setup is that a malicious actor can alternate between resending and changing the email address (to something like `user+$idx@domain`, delivered to the same inbox) to effectively halving the rate limit. I do not think there's a better solution, and this feels like such a small attack surface that I'd deem it acceptable. The way the code works after this change is that `ActivatePost` will now check the `MailChangeLimit_user` key rather than `MailResendLimit_user`, and if we're within the limit, it will set `MailChangedJustNow_user`. The `Activate` method - which sends the activation email, whether it is a normal resend, or one following an email change - will check `MailChangedJustNow_user`, and if it is set, it will check the rate limit against `MailChangedLimit_user`, otherwise against `MailResendLimit_user`, and then will delete the `MailChangedJustNow_user` key from the cache. Fixes #2040. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commite35d2af2e5
) (cherry picked from commit03989418a7
) (cherry picked from commitf50e0dfe5e
) (cherry picked from commitcad9184a36
) (cherry picked from commite2da5d7fe1
) (cherry picked from commit3a80534d4d
)
62 lines
2.5 KiB
Go HTML Template
62 lines
2.5 KiB
Go HTML Template
{{template "base/head" .}}
|
|
<div role="main" aria-label="{{.Title}}" class="page-content user activate">
|
|
<div class="ui middle very relaxed page grid">
|
|
<div class="column">
|
|
<form class="ui form ignore-dirty" action="{{AppSubUrl}}/user/activate" method="post">
|
|
{{.CsrfTokenHtml}}
|
|
<h2 class="ui top attached header">
|
|
{{ctx.Locale.Tr "auth.active_your_account"}}
|
|
</h2>
|
|
<div class="ui attached segment">
|
|
{{template "base/alert" .}}
|
|
{{if .IsActivatePage}}
|
|
{{if .ServiceNotEnabled}}
|
|
<p class="center">{{ctx.Locale.Tr "auth.disable_register_mail"}}</p>
|
|
{{else if .ResendLimited}}
|
|
<p class="center">{{ctx.Locale.Tr "auth.resent_limit_prompt"}}</p>
|
|
{{else}}
|
|
<p>{{ctx.Locale.Tr "auth.confirmation_mail_sent_prompt" (.SignedUser.Email|Escape) .ActiveCodeLives | Str2html}}</p>
|
|
{{end}}
|
|
{{else}}
|
|
{{if .NeedsPassword}}
|
|
<div class="required inline field">
|
|
<label for="password">{{ctx.Locale.Tr "password"}}</label>
|
|
<input id="password" name="password" type="password" autocomplete="off" required>
|
|
</div>
|
|
<div class="inline field">
|
|
<label></label>
|
|
<button class="ui primary button">{{ctx.Locale.Tr "install.confirm_password"}}</button>
|
|
</div>
|
|
<input id="code" name="code" type="hidden" value="{{.Code}}">
|
|
{{else if .IsSendRegisterMail}}
|
|
<p>{{ctx.Locale.Tr "auth.confirmation_mail_sent_prompt" (.Email|Escape) .ActiveCodeLives | Str2html}}</p>
|
|
{{else if .IsCodeInvalid}}
|
|
<p>{{ctx.Locale.Tr "auth.invalid_code"}}</p>
|
|
{{else if .IsPasswordInvalid}}
|
|
<p>{{ctx.Locale.Tr "auth.invalid_password"}}</p>
|
|
{{else if .ManualActivationOnly}}
|
|
<p class="center">{{ctx.Locale.Tr "auth.manual_activation_only"}}</p>
|
|
{{else}}
|
|
<p>{{ctx.Locale.Tr "auth.has_unconfirmed_mail" (.SignedUser.Name|Escape) (.SignedUser.Email|Escape) | Str2html}}</p>
|
|
<div class="divider"></div>
|
|
<details class="inline field">
|
|
<summary>{{ctx.Locale.Tr "auth.change_unconfirmed_email_summary"}}</summary>
|
|
|
|
<p>{{ctx.Locale.Tr "auth.change_unconfirmed_email"}}</p>
|
|
<div class="inline field">
|
|
<label for="email">{{ctx.Locale.Tr "email"}}</label>
|
|
<input id="email" name="email" type="email" autocomplete="on">
|
|
</div>
|
|
</details>
|
|
|
|
<div class="text right">
|
|
<button class="ui primary button">{{ctx.Locale.Tr "auth.resend_mail"}}</button>
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{template "base/footer" .}}
|