diff options
author | Zettat123 <zettat123@gmail.com> | 2024-03-11 07:07:36 +0100 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-03-20 08:46:28 +0100 |
commit | 2559c80bec27a41967b355d214253a83b9ee5dad (patch) | |
tree | 50fb4df5394f488f01dc94377b9580ca317713d8 /routers/api/v1/admin | |
parent | Fix inconsistent rendering of block mathematical expressions (#29677) (diff) | |
download | forgejo-2559c80bec27a41967b355d214253a83b9ee5dad.tar.xz forgejo-2559c80bec27a41967b355d214253a83b9ee5dad.zip |
Add a warning for disallowed email domains (#29658)
Resolve #29660
Follow #29522 and #29609
Add a warning for disallowed email domains when admins manually add/edit
users.
Thanks @yp05327 for the
[comment](https://github.com/go-gitea/gitea/pull/29605#issuecomment-1980105119)
![image](https://github.com/go-gitea/gitea/assets/15528715/6737b221-a3a2-4180-9ef8-b846c10f96e0)
(cherry picked from commit 4129e0e79bbf30e4297efd33feb2602c40322d10)
Diffstat (limited to 'routers/api/v1/admin')
-rw-r--r-- | routers/api/v1/admin/user.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 986305d423..87a5b28fad 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -147,6 +147,11 @@ func CreateUser(ctx *context.APIContext) { } return } + + if !user_model.IsEmailDomainAllowed(u.Email) { + ctx.Resp.Header().Add("X-Gitea-Warning", fmt.Sprintf("the domain of user email %s conflicts with EMAIL_DOMAIN_ALLOWLIST or EMAIL_DOMAIN_BLOCKLIST", u.Email)) + } + log.Trace("Account created by admin (%s): %s", ctx.Doer.Name, u.Name) // Send email notification. @@ -220,6 +225,10 @@ func EditUser(ctx *context.APIContext) { } return } + + if !user_model.IsEmailDomainAllowed(*form.Email) { + ctx.Resp.Header().Add("X-Gitea-Warning", fmt.Sprintf("the domain of user email %s conflicts with EMAIL_DOMAIN_ALLOWLIST or EMAIL_DOMAIN_BLOCKLIST", *form.Email)) + } } opts := &user_service.UpdateOptions{ |