[MM-36472] Fix inconsistencies in Roles columns (#18390)
* Fix inconsistencies in Roles columns * Add new migrations
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
305e4793c3
Коммит
177680f08c
@@ -4,6 +4,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -78,6 +79,27 @@ func (s *Session) DeepCopy() *Session {
|
||||
return ©Session
|
||||
}
|
||||
|
||||
func (s *Session) IsValid() *AppError {
|
||||
if !IsValidId(s.Id) {
|
||||
return NewAppError("Session.IsValid", "model.session.is_valid.id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !IsValidId(s.UserId) {
|
||||
return NewAppError("Session.IsValid", "model.session.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if s.CreateAt == 0 {
|
||||
return NewAppError("Session.IsValid", "model.session.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(s.Roles) > UserRolesMaxLength {
|
||||
return NewAppError("Session.IsValid", "model.session.is_valid.roles_limit.app_error",
|
||||
map[string]interface{}{"Limit": UserRolesMaxLength}, "session_id="+s.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Session) PreSave() {
|
||||
if s.Id == "" {
|
||||
s.Id = NewId()
|
||||
|
||||
Ссылка в новой задаче
Block a user