1
0
Fork 0
forked from forgejo/forgejo

Skip email domain check when admins edit user emails (#29609)

Follow #29522

Administrators should be able to set a user's email address even if the
email address is not in `EMAIL_DOMAIN_ALLOWLIST`

(cherry picked from commit 136dd99e86eea9c8bfe61b972a12b395655171e8)
This commit is contained in:
Zettat123 2024-03-06 00:51:56 +08:00 committed by Earl Warren
parent 02384ff9ad
commit e7afba21ce
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
6 changed files with 53 additions and 9 deletions

View file

@ -209,7 +209,7 @@ func EditUser(ctx *context.APIContext) {
}
if form.Email != nil {
if err := user_service.AddOrSetPrimaryEmailAddress(ctx, ctx.ContextUser, *form.Email); err != nil {
if err := user_service.AdminAddOrSetPrimaryEmailAddress(ctx, ctx.ContextUser, *form.Email); err != nil {
switch {
case user_model.IsErrEmailCharIsNotSupported(err), user_model.IsErrEmailInvalid(err):
ctx.Error(http.StatusBadRequest, "EmailInvalid", err)