diff options
author | techknowlogick <techknowlogick@gitea.com> | 2024-09-09 17:05:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 17:05:16 -0400 |
commit | f183783baa67e7da0b0ae0909d3d6cb3045c0501 (patch) | |
tree | f8a232899d17c11dd0cb9ad132a552329e1804e5 /routers/web | |
parent | a323a82ec4bde6ae39b97200439829bf67c0d31e (diff) | |
download | gitea-f183783baa67e7da0b0ae0909d3d6cb3045c0501.tar.gz gitea-f183783baa67e7da0b0ae0909d3d6cb3045c0501.zip |
Save initial signup information for users to aid in spam prevention (#31852)
This will allow instance admins to view signup pattern patterns for
public instances. It is modelled after discourse, mastodon, and
MediaWiki's approaches.
Note: This has privacy implications, but as the above-stated open-source
projects take this approach, especially MediaWiki, which I have no doubt
looked into this thoroughly, it is likely okay for us, too. However, I
would be appreciative of any feedback on how this could be improved.
---------
Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/admin/users.go | 2 | ||||
-rw-r--r-- | routers/web/auth/auth.go | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index 34bb1dfe26..48ff8ea04b 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -177,7 +177,7 @@ func NewUserPost(ctx *context.Context) { u.MustChangePassword = form.MustChangePassword } - if err := user_model.AdminCreateUser(ctx, u, overwriteDefault); err != nil { + if err := user_model.AdminCreateUser(ctx, u, &user_model.Meta{}, overwriteDefault); err != nil { switch { case user_model.IsErrUserAlreadyExist(err): ctx.Data["Err_UserName"] = true diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index f295cf039f..b86c1ff1c2 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -541,7 +541,11 @@ func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form any // createUserInContext creates a user and handles errors within a given context. // Optionally a template can be specified. func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) { - if err := user_model.CreateUser(ctx, u, overwrites); err != nil { + meta := &user_model.Meta{ + InitialIP: ctx.RemoteAddr(), + InitialUserAgent: ctx.Req.UserAgent(), + } + if err := user_model.CreateUser(ctx, u, meta, overwrites); err != nil { if allowLink && (user_model.IsErrUserAlreadyExist(err) || user_model.IsErrEmailAlreadyUsed(err)) { if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingAuto { var user *user_model.User |