[MM-22791] Prevent account creation if new user does not have allowed domain for the team (#14012)

* app/user: prevent user creation for restricted domains for a team

* app/user_test: add error message checks to CreateUserWithInviteId
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2020-03-17 17:23:59 +03:00
коммит произвёл GitHub
родитель 42081a1441
Коммит 4823b3861a
2 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@@ -121,6 +121,10 @@ func (a *App) CreateUserWithInviteId(user *model.User, inviteId string) (*model.
return nil, model.NewAppError("CreateUserWithInviteId", "app.team.invite_id.group_constrained.error", nil, "", http.StatusForbidden)
}
if !CheckUserDomain(user, team.AllowedDomains) {
return nil, model.NewAppError("CreateUserWithInviteId", "api.team.invite_members.invalid_email.app_error", map[string]interface{}{"Addresses": team.AllowedDomains}, "", http.StatusForbidden)
}
user.EmailVerified = false
ruser, err := a.CreateUser(user)