Migrate User Store methods related to enterprise to sync by default (#11332)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7e918e38bc
Коммит
6df57d7a83
32
app/user.go
32
app/user.go
@@ -173,14 +173,12 @@ func (a *App) IsUserSignUpAllowed() *model.AppError {
|
||||
|
||||
func (a *App) IsFirstUserAccount() bool {
|
||||
if a.SessionCacheLength() == 0 {
|
||||
cr := <-a.Srv.Store.User().Count(model.UserCountOptions{
|
||||
IncludeDeleted: true,
|
||||
})
|
||||
if cr.Err != nil {
|
||||
mlog.Error(fmt.Sprint(cr.Err))
|
||||
count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if err != nil {
|
||||
mlog.Error(fmt.Sprint(err))
|
||||
return false
|
||||
}
|
||||
if cr.Data.(int64) <= 0 {
|
||||
if count <= 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -246,13 +244,11 @@ func (a *App) createUserOrGuest(user *model.User, guest bool) (*model.User, *mod
|
||||
|
||||
// Below is a special case where the first user in the entire
|
||||
// system is granted the system_admin role
|
||||
result := <-a.Srv.Store.User().Count(model.UserCountOptions{
|
||||
IncludeDeleted: true,
|
||||
})
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeDeleted: true})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Data.(int64) <= 0 {
|
||||
if count <= 0 {
|
||||
user.Roles = model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID
|
||||
}
|
||||
|
||||
@@ -1088,8 +1084,8 @@ func (a *App) UpdateUserAuth(userId string, userAuth *model.UserAuth) (*model.Us
|
||||
} else {
|
||||
userAuth.Password = ""
|
||||
|
||||
if result := <-a.Srv.Store.User().UpdateAuthData(userId, userAuth.AuthService, userAuth.AuthData, "", false); result.Err != nil {
|
||||
return nil, result.Err
|
||||
if _, err := a.Srv.Store.User().UpdateAuthData(userId, userAuth.AuthService, userAuth.AuthData, "", false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1639,15 +1635,15 @@ func (a *App) GetVerifyEmailToken(token string) (*model.Token, *model.AppError)
|
||||
|
||||
// GetTotalUsersStats is used for the DM list total
|
||||
func (a *App) GetTotalUsersStats(viewRestrictions *model.ViewUsersRestrictions) (*model.UsersStats, *model.AppError) {
|
||||
result := <-a.Srv.Store.User().Count(model.UserCountOptions{
|
||||
count, err := a.Srv.Store.User().Count(model.UserCountOptions{
|
||||
IncludeBotAccounts: true,
|
||||
ViewRestrictions: viewRestrictions,
|
||||
})
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stats := &model.UsersStats{
|
||||
TotalUsersCount: result.Data.(int64),
|
||||
TotalUsersCount: count,
|
||||
}
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user