diff options
author | Zettat123 <zettat123@gmail.com> | 2024-03-11 14:07:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 06:07:36 +0000 |
commit | 4129e0e79bbf30e4297efd33feb2602c40322d10 (patch) | |
tree | 8b9b9d18835cc3dfd290f204f8802e7df860a0f8 /services/forms | |
parent | 8fc1a8f0eb642c574610a346e858d42c433ebe01 (diff) | |
download | gitea-4129e0e79bbf30e4297efd33feb2602c40322d10.tar.gz gitea-4129e0e79bbf30e4297efd33feb2602c40322d10.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)
Diffstat (limited to 'services/forms')
-rw-r--r-- | services/forms/user_form.go | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/services/forms/user_form.go b/services/forms/user_form.go index 416592bfda..e2e6c208f7 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -10,9 +10,9 @@ import ( "strings" auth_model "code.gitea.io/gitea/models/auth" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/validation" "code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/services/context" @@ -109,11 +109,7 @@ func (f *RegisterForm) Validate(req *http.Request, errs binding.Errors) binding. // domains in the whitelist or if it doesn't match any of // domains in the blocklist, if any such list is not empty. func (f *RegisterForm) IsEmailDomainAllowed() bool { - if len(setting.Service.EmailDomainAllowList) == 0 { - return !validation.IsEmailDomainListed(setting.Service.EmailDomainBlockList, f.Email) - } - - return validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, f.Email) + return user_model.IsEmailDomainAllowed(f.Email) } // MustChangePasswordForm form for updating your password after account creation |