Modifying permissions system. (#3897)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
05af5d14b8
Коммит
1e7985a87a
@@ -9,10 +9,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
ROLE_TEAM_ADMIN = "admin"
|
||||
)
|
||||
|
||||
type TeamMember struct {
|
||||
TeamId string `json:"team_id"`
|
||||
UserId string `json:"user_id"`
|
||||
@@ -59,31 +55,6 @@ func TeamMembersFromJson(data io.Reader) []*TeamMember {
|
||||
}
|
||||
}
|
||||
|
||||
func IsValidTeamRoles(teamRoles string) bool {
|
||||
|
||||
roles := strings.Split(teamRoles, " ")
|
||||
|
||||
for _, r := range roles {
|
||||
if !isValidTeamRole(r) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func isValidTeamRole(role string) bool {
|
||||
if role == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
if role == ROLE_TEAM_ADMIN {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func IsInTeamRole(teamRoles string, inRole string) bool {
|
||||
roles := strings.Split(teamRoles, " ")
|
||||
|
||||
@@ -98,7 +69,7 @@ func IsInTeamRole(teamRoles string, inRole string) bool {
|
||||
}
|
||||
|
||||
func (o *TeamMember) IsTeamAdmin() bool {
|
||||
return IsInTeamRole(o.Roles, ROLE_TEAM_ADMIN)
|
||||
return true
|
||||
}
|
||||
|
||||
func (o *TeamMember) IsValid() *AppError {
|
||||
@@ -111,11 +82,18 @@ func (o *TeamMember) IsValid() *AppError {
|
||||
return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.user_id.app_error", nil, "")
|
||||
}
|
||||
|
||||
for _, role := range strings.Split(o.Roles, " ") {
|
||||
if !(role == "" || role == ROLE_TEAM_ADMIN) {
|
||||
/*for _, role := range strings.Split(o.Roles, " ") {
|
||||
if !(role == "" || role == ROLE_TEAM_ADMIN.Id) {
|
||||
return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.role.app_error", nil, "role="+role)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *TeamMember) PreUpdate() {
|
||||
}
|
||||
|
||||
func (o *TeamMember) GetRoles() []string {
|
||||
return strings.Fields(o.Roles)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user