Cleanup usage of global logger (#26835)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
92a6c6517d
Коммит
30d450c4d8
@@ -337,10 +337,10 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
|
||||
if limitErr != nil {
|
||||
// we don't want to break the create user flow just because of this.
|
||||
// So, we log the error, not return
|
||||
mlog.Error("Error fetching user limits in createUserOrGuest", mlog.Err(limitErr))
|
||||
c.Logger().Error("Error fetching user limits in createUserOrGuest", mlog.Err(limitErr))
|
||||
} else {
|
||||
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
|
||||
mlog.Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Created user exceeds the total activated users limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
||||
c.Logger().Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Created user exceeds the total activated users limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,10 +1072,10 @@ func (a *App) UpdateActive(c request.CTX, user *model.User, active bool) (*model
|
||||
if active {
|
||||
userLimits, appErr := a.GetServerLimits()
|
||||
if appErr != nil {
|
||||
mlog.Error("Error fetching user limits in UpdateActive", mlog.Err(appErr))
|
||||
c.Logger().Error("Error fetching user limits in UpdateActive", mlog.Err(appErr))
|
||||
} else {
|
||||
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
|
||||
mlog.Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Activated user exceeds the total active user limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
||||
c.Logger().Warn("ERROR_SAFETY_LIMITS_EXCEEDED: Activated user exceeds the total active user limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1533,7 +1533,7 @@ func (a *App) resetPasswordFromToken(c request.CTX, userSuppliedTokenString, new
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppError) {
|
||||
func (a *App) SendPasswordReset(rctx request.CTX, email string, siteURL string) (bool, *model.AppError) {
|
||||
user, err := a.GetUserByEmail(email)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
@@ -1543,7 +1543,7 @@ func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppE
|
||||
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.sso.app_error", nil, "userId="+user.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
token, err := a.CreatePasswordRecoveryToken(user.Id, user.Email)
|
||||
token, err := a.CreatePasswordRecoveryToken(rctx, user.Id, user.Email)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -1556,7 +1556,7 @@ func (a *App) SendPasswordReset(email string, siteURL string) (bool, *model.AppE
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a *App) CreatePasswordRecoveryToken(userID, email string) (*model.Token, *model.AppError) {
|
||||
func (a *App) CreatePasswordRecoveryToken(rctx request.CTX, userID, email string) (*model.Token, *model.AppError) {
|
||||
tokenExtra := struct {
|
||||
UserId string
|
||||
Email string
|
||||
@@ -1572,7 +1572,7 @@ func (a *App) CreatePasswordRecoveryToken(userID, email string) (*model.Token, *
|
||||
// remove any previously created tokens for user
|
||||
appErr := a.InvalidatePasswordRecoveryTokensForUser(userID)
|
||||
if appErr != nil {
|
||||
mlog.Warn("Error while deleting additional user tokens.", mlog.Err(err))
|
||||
rctx.Logger().Warn("Error while deleting additional user tokens.", mlog.Err(err))
|
||||
}
|
||||
|
||||
token := model.NewToken(TokenTypePasswordRecovery, string(jsonData))
|
||||
@@ -2863,14 +2863,14 @@ func getProfileImageDirectory(userID string) string {
|
||||
return filepath.Join("users", userID)
|
||||
}
|
||||
|
||||
func (a *App) UserIsFirstAdmin(user *model.User) bool {
|
||||
func (a *App) UserIsFirstAdmin(rctx request.CTX, user *model.User) bool {
|
||||
if !user.IsSystemAdmin() {
|
||||
return false
|
||||
}
|
||||
|
||||
systemAdminUsers, errServer := a.Srv().Store().User().GetSystemAdminProfiles()
|
||||
if errServer != nil {
|
||||
mlog.Warn("Failed to get system admins to check for first admin from Mattermost.")
|
||||
rctx.Logger().Warn("Failed to get system admins to check for first admin from Mattermost.")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user