mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
GH-11466 Migrate User.UpdatePassword to Sync by default (#11495)
* GH-11466 Migrate User.UpdatePassword to Sync by default * GH-11466 format fix
This commit is contained in:
@@ -240,16 +240,14 @@ func (us SqlUserStore) UpdateUpdateAt(userId string) (int64, *model.AppError) {
|
||||
return curTime, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
updateAt := model.GetMillis()
|
||||
func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) *model.AppError {
|
||||
updateAt := model.GetMillis()
|
||||
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET Password = :Password, LastPasswordUpdate = :LastPasswordUpdate, UpdateAt = :UpdateAt, AuthData = NULL, AuthService = '', FailedAttempts = 0 WHERE Id = :UserId", map[string]interface{}{"Password": hashedPassword, "LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlUserStore.UpdatePassword", "store.sql_user.update_password.app_error", nil, "id="+userId+", "+err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = userId
|
||||
}
|
||||
})
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET Password = :Password, LastPasswordUpdate = :LastPasswordUpdate, UpdateAt = :UpdateAt, AuthData = NULL, AuthService = '', FailedAttempts = 0 WHERE Id = :UserId", map[string]interface{}{"Password": hashedPassword, "LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId}); err != nil {
|
||||
return model.NewAppError("SqlUserStore.UpdatePassword", "store.sql_user.update_password.app_error", nil, "id="+userId+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError {
|
||||
|
||||
@@ -253,8 +253,8 @@ type UserStore interface {
|
||||
Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, *model.AppError)
|
||||
UpdateLastPictureUpdate(userId string) *model.AppError
|
||||
ResetLastPictureUpdate(userId string) *model.AppError
|
||||
UpdatePassword(userId, newPassword string) *model.AppError
|
||||
UpdateUpdateAt(userId string) (int64, *model.AppError)
|
||||
UpdatePassword(userId, newPassword string) StoreChannel
|
||||
UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, *model.AppError)
|
||||
UpdateMfaSecret(userId, secret string) *model.AppError
|
||||
UpdateMfaActive(userId string, active bool) StoreChannel
|
||||
|
||||
@@ -1150,15 +1150,15 @@ func (_m *UserStore) UpdateMfaSecret(userId string, secret string) *model.AppErr
|
||||
}
|
||||
|
||||
// UpdatePassword provides a mock function with given fields: userId, newPassword
|
||||
func (_m *UserStore) UpdatePassword(userId string, newPassword string) store.StoreChannel {
|
||||
func (_m *UserStore) UpdatePassword(userId string, newPassword string) *model.AppError {
|
||||
ret := _m.Called(userId, newPassword)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, string) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.AppError); ok {
|
||||
r0 = rf(userId, newPassword)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1800,7 +1800,7 @@ func testUserStoreUpdatePassword(t *testing.T, ss store.Store) {
|
||||
|
||||
hashedPassword := model.HashPassword("newpwd")
|
||||
|
||||
if err := (<-ss.User().UpdatePassword(u1.Id, hashedPassword)).Err; err != nil {
|
||||
if err := ss.User().UpdatePassword(u1.Id, hashedPassword); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user