1
0
Fork 0
forgejo/models
Gergely Nagy 03989418a7
[GITEA] Allow changing the email address before activation
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 commit aaaece28e4)
(cherry picked from commit 639dafabec)
(cherry picked from commit d699c12ceb)

[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.

See e7cb8da2a8 * Always enable caches (#28527)

(cherry picked from commit 43ded8ee30)

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 commit e35d2af2e5)
2024-01-01 15:36:14 +01:00
..
actions [GITEA] allow viewing the latest Action Run on the web 2024-01-01 15:27:12 +01:00
activities Refactor timeutil package (#28623) 2023-12-28 10:09:57 +00:00
admin
asymkey [GITEA] Add noreply email address as verified for SSH signed Git commits 2024-01-01 15:24:07 +01:00
auth [GITEA] Drop sha256-simd in favor of stdlib 2024-01-01 15:20:56 +01:00
avatars Refactor some legacy code and remove unused code (#28622) 2023-12-28 09:38:59 +00:00
db [GITEA] Add slow SQL query warning 2024-01-01 15:20:56 +01:00
dbfs
fixtures [GITEA] Add noreply email address as verified for SSH signed Git commits 2024-01-01 15:24:07 +01:00
forgejo/semver [SEMVER] store SemVer in ForgejoSemVer after a database upgrade 2024-01-01 13:50:27 +01:00
forgejo_migrations [SECURITY] Rework long-term authentication 2024-01-01 13:50:30 +01:00
git Refactor some legacy code and remove unused code (#28622) 2023-12-28 09:38:59 +00:00
issues [FEAT] allow setting the update date on issues and comments 2024-01-01 13:50:27 +01:00
migrations [GITEA] new doctor check: fix-push-mirrors-without-git-remote (#1853) 2024-01-01 15:27:12 +01:00
organization Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 2023-12-07 15:27:36 +08:00
packages
perm Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 2023-12-07 15:27:36 +08:00
project
pull [GITEA] GetScheduledMergeByPullID may involve a system user 2024-01-01 15:27:12 +01:00
repo [GITEA] new doctor check: fix-push-mirrors-without-git-remote (#1853) 2024-01-01 15:27:12 +01:00
secret
shared/types
system Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
unit
unittest [GITEA] Enable mocked HTTP responses for GitLab migration test 2024-01-01 15:24:08 +01:00
user [GITEA] Allow changing the email address before activation 2024-01-01 15:36:14 +01:00
webhook Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
error.go
fixture_generation.go
fixture_test.go
main_test.go
org.go Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
org_team.go Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 2023-12-07 15:27:36 +08:00
org_team_test.go
org_test.go
repo.go Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
repo_test.go
repo_transfer.go
repo_transfer_test.go