[MM-29523] EmailVerified flag can be user as parameter (#16031)
* EmailVerified flag can be used as a parameter But only when if the user creator is an admin
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
76f1bfb941
Коммит
f5531a5a43
@@ -24,11 +24,20 @@ func TestCreateUser(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||
user := model.User{
|
||||
Email: th.GenerateTestEmail(),
|
||||
Nickname: "Corey Hulen",
|
||||
Password: "hello1",
|
||||
Username: GenerateTestUsername(),
|
||||
Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID,
|
||||
EmailVerified: true,
|
||||
}
|
||||
|
||||
ruser, resp := th.Client.CreateUser(&user)
|
||||
CheckNoError(t, resp)
|
||||
CheckCreatedStatus(t, resp)
|
||||
// Creating a user as a regular user with verified flag should not verify the new user.
|
||||
require.False(t, ruser.EmailVerified)
|
||||
|
||||
_, _ = th.Client.Login(user.Email, user.Password)
|
||||
|
||||
@@ -67,9 +76,11 @@ func TestCreateUser(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false })
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
user2 := &model.User{Email: th.GenerateTestEmail(), Password: "Password1", Username: GenerateTestUsername()}
|
||||
_, resp = client.CreateUser(user2)
|
||||
user2 := &model.User{Email: th.GenerateTestEmail(), Password: "Password1", Username: GenerateTestUsername(), EmailVerified: true}
|
||||
ruser2, resp := client.CreateUser(user2)
|
||||
CheckNoError(t, resp)
|
||||
// Creating a user as sysadmin should verify the user with the EmailVerified flag.
|
||||
require.True(t, ruser2.EmailVerified)
|
||||
|
||||
r, err := client.DoApiPost("/users", "garbage")
|
||||
require.NotNil(t, err, "should have errored")
|
||||
|
||||
@@ -540,11 +540,11 @@ func (u *User) SanitizeInput(isAdmin bool) {
|
||||
if !isAdmin {
|
||||
u.AuthData = NewString("")
|
||||
u.AuthService = ""
|
||||
u.EmailVerified = false
|
||||
}
|
||||
u.LastPasswordUpdate = 0
|
||||
u.LastPictureUpdate = 0
|
||||
u.FailedAttempts = 0
|
||||
u.EmailVerified = false
|
||||
u.MfaActive = false
|
||||
u.MfaSecret = ""
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user