mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrate User.UpdateFailedPasswordAttempts to sync by default (#11507)
* Migrate User.UpdateFailedPasswordAttempts to sync by default * Removed unused return value
This commit is contained in:
committed by
Jesús Espino
parent
2ecca12bed
commit
7da08e7a0f
@@ -255,14 +255,12 @@ func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) store.Store
|
||||
})
|
||||
}
|
||||
|
||||
func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET FailedAttempts = :FailedAttempts WHERE Id = :UserId", map[string]interface{}{"FailedAttempts": attempts, "UserId": userId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlUserStore.UpdateFailedPasswordAttempts", "store.sql_user.update_failed_pwd_attempts.app_error", nil, "user_id="+userId, http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = userId
|
||||
}
|
||||
})
|
||||
func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Users SET FailedAttempts = :FailedAttempts WHERE Id = :UserId", map[string]interface{}{"FailedAttempts": attempts, "UserId": userId}); err != nil {
|
||||
return model.NewAppError("SqlUserStore.UpdateFailedPasswordAttempts", "store.sql_user.update_failed_pwd_attempts.app_error", nil, "user_id="+userId, http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, *model.AppError) {
|
||||
|
||||
@@ -282,7 +282,7 @@ type UserStore interface {
|
||||
VerifyEmail(userId, email string) (string, *model.AppError)
|
||||
GetEtagForAllProfiles() string
|
||||
GetEtagForProfiles(teamId string) string
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
|
||||
UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError
|
||||
GetSystemAdminProfiles() (map[string]*model.User, *model.AppError)
|
||||
PermanentDelete(userId string) *model.AppError
|
||||
AnalyticsActiveCount(time int64) (int64, *model.AppError)
|
||||
|
||||
@@ -1072,15 +1072,15 @@ func (_m *UserStore) UpdateAuthData(userId string, service string, authData *str
|
||||
}
|
||||
|
||||
// UpdateFailedPasswordAttempts provides a mock function with given fields: userId, attempts
|
||||
func (_m *UserStore) UpdateFailedPasswordAttempts(userId string, attempts int) store.StoreChannel {
|
||||
func (_m *UserStore) UpdateFailedPasswordAttempts(userId string, attempts int) *model.AppError {
|
||||
ret := _m.Called(userId, attempts)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string, int) *model.AppError); ok {
|
||||
r0 = rf(userId, attempts)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ func testUserStoreUpdateFailedPasswordAttempts(t *testing.T, ss store.Store) {
|
||||
defer func() { require.Nil(t, ss.User().PermanentDelete(u1.Id)) }()
|
||||
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1))
|
||||
|
||||
if err := (<-ss.User().UpdateFailedPasswordAttempts(u1.Id, 3)).Err; err != nil {
|
||||
if err := ss.User().UpdateFailedPasswordAttempts(u1.Id, 3); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user