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)

(cherry picked from commit 4129e0e79bbf30e4297efd33feb2602c40322d10)
This commit is contained in:
parent
b6e480fcbb
commit
2559c80bec
6 changed files with 33 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue