[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
@@ -1025,9 +1025,10 @@ func (us SqlUserStore) GetForLogin(loginId string, allowSignInWithUsername, allo
|
||||
})
|
||||
}
|
||||
|
||||
func (us SqlUserStore) VerifyEmail(userId string) store.StoreChannel {
|
||||
func (us SqlUserStore) VerifyEmail(userId, email string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET EmailVerified = true WHERE Id = :UserId", map[string]interface{}{"UserId": userId}); err != nil {
|
||||
curTime := model.GetMillis()
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET Email = :email, EmailVerified = true, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"email": email, "Time": curTime, "UserId": userId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlUserStore.VerifyEmail", "store.sql_user.verify_email.app_error", nil, "userId="+userId+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ type UserStore interface {
|
||||
GetAllUsingAuthService(authService string) StoreChannel
|
||||
GetByUsername(username string) StoreChannel
|
||||
GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail bool) StoreChannel
|
||||
VerifyEmail(userId string) StoreChannel
|
||||
VerifyEmail(userId, email string) StoreChannel
|
||||
GetEtagForAllProfiles() StoreChannel
|
||||
GetEtagForProfiles(teamId string) StoreChannel
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
|
||||
|
||||
@@ -833,13 +833,13 @@ func (_m *UserStore) UpdateUpdateAt(userId string) store.StoreChannel {
|
||||
return r0
|
||||
}
|
||||
|
||||
// VerifyEmail provides a mock function with given fields: userId
|
||||
func (_m *UserStore) VerifyEmail(userId string) store.StoreChannel {
|
||||
ret := _m.Called(userId)
|
||||
// VerifyEmail provides a mock function with given fields: userId, email
|
||||
func (_m *UserStore) VerifyEmail(userId string, email string) store.StoreChannel {
|
||||
ret := _m.Called(userId, email)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
r0 = rf(userId)
|
||||
if rf, ok := ret.Get(0).(func(string, string) store.StoreChannel); ok {
|
||||
r0 = rf(userId, email)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
|
||||
Ссылка в новой задаче
Block a user