[MM-13840] Change eMail as a post-verification action (#10253)
* Change eMail as a post-verification action * Fix broken test * comment for special behavior, tests * govet * Check for already existent eMails when require email verification is turned on before accepting update
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1218e774ba
Коммит
f046163a12
@@ -294,7 +294,7 @@ func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User {
|
||||
}
|
||||
|
||||
ruser.Password = "Password1"
|
||||
store.Must(me.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
store.Must(me.App.Srv.Store.User().VerifyEmail(ruser.Id, ruser.Email))
|
||||
utils.EnableDebugLogForTest()
|
||||
return ruser
|
||||
}
|
||||
|
||||
@@ -1355,7 +1355,7 @@ func sendVerificationEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.App.SendEmailVerification(user); err != nil {
|
||||
if err = c.App.SendEmailVerification(user, user.Email); err != nil {
|
||||
// Don't want to leak whether the email is valid or not
|
||||
mlog.Error(err.Error())
|
||||
ReturnStatusOK(w)
|
||||
|
||||
@@ -1220,7 +1220,7 @@ func TestUpdateUserAuth(t *testing.T) {
|
||||
user := th.CreateUser()
|
||||
|
||||
th.LinkUserToTeam(user, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id, user.Email))
|
||||
|
||||
userAuth := &model.UserAuth{}
|
||||
userAuth.AuthData = user.AuthData
|
||||
@@ -1260,7 +1260,7 @@ func TestUpdateUserAuth(t *testing.T) {
|
||||
// Regular user can not use endpoint
|
||||
user2 := th.CreateUser()
|
||||
th.LinkUserToTeam(user2, team)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id, user2.Email))
|
||||
|
||||
th.SystemAdminClient.Login(user2.Email, "passwd1")
|
||||
|
||||
@@ -2220,11 +2220,12 @@ func TestVerifyUserEmail(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||
email := th.GenerateTestEmail()
|
||||
user := model.User{Email: email, Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||
|
||||
ruser, _ := th.Client.CreateUser(&user)
|
||||
|
||||
token, err := th.App.CreateVerifyEmailToken(ruser.Id)
|
||||
token, err := th.App.CreateVerifyEmailToken(ruser.Id, email)
|
||||
if err != nil {
|
||||
t.Fatal("Unable to create email verify token")
|
||||
}
|
||||
|
||||
@@ -304,12 +304,12 @@ func TestWebSocketStatuses(t *testing.T) {
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser := Client.Must(Client.CreateUser(&user)).(*model.User)
|
||||
th.LinkUserToTeam(ruser, rteam)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser.Id, ruser.Email))
|
||||
|
||||
user2 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||
ruser2 := Client.Must(Client.CreateUser(&user2)).(*model.User)
|
||||
th.LinkUserToTeam(ruser2, rteam)
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser2.Id))
|
||||
store.Must(th.App.Srv.Store.User().VerifyEmail(ruser2.Id, ruser2.Email))
|
||||
|
||||
Client.Login(user.Email, user.Password)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user