Added count exceeded warning (#25817)

* Added count exceeded warning

* lint fix

* Updated message

* Update server/channels/app/user.go

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* added check for activating user

* Updated copy

---------

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
This commit is contained in:
Harshil Sharma
2024-01-12 06:48:52 +05:30
committed by GitHub
parent 4d96c11314
commit 3047700c0b

View File

@@ -318,6 +318,17 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
}(ruser.Id)
}
userLimits, appErr := a.GetUserLimits()
if appErr != 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(appErr))
} else {
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
mlog.Warn("ERROR_USER_LIMITS_EXCEEDED: Created user exceeds the total activated users limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
}
}
return ruser, nil
}
@@ -1013,6 +1024,17 @@ func (a *App) UpdateActive(c request.CTX, user *model.User, active bool) (*model
})
}
if active {
userLimits, appErr := a.GetUserLimits()
if appErr != nil {
mlog.Error("Error fetching user limits in UpdateActive", mlog.Err(appErr))
} else {
if userLimits.ActiveUserCount > userLimits.MaxUsersLimit {
mlog.Warn("ERROR_USER_LIMITS_EXCEEDED: Activated user exceeds the total active user limit.", mlog.Int("user_limit", userLimits.MaxUsersLimit))
}
}
}
return ruser, nil
}