Renaming ROLE_ADMIN to ROLE_TEAM_ADMIN
Этот коммит содержится в:
@@ -191,7 +191,7 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(c.Session.Roles, model.ROLE_ADMIN) {
|
if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
c.Err = model.NewAppError("updateChannel", "You do not have the appropriate permissions", "")
|
c.Err = model.NewAppError("updateChannel", "You do not have the appropriate permissions", "")
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
@@ -514,7 +514,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(c.Session.Roles, model.ROLE_ADMIN) {
|
if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
c.Err = model.NewAppError("deleteChannel", "You do not have the appropriate permissions", "")
|
c.Err = model.NewAppError("deleteChannel", "You do not have the appropriate permissions", "")
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
@@ -756,7 +756,7 @@ func removeChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(c.Session.Roles, model.ROLE_ADMIN) {
|
if !strings.Contains(channelMember.Roles, model.CHANNEL_ROLE_ADMIN) && !strings.Contains(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
c.Err = model.NewAppError("updateChannel", "You do not have the appropriate permissions ", "")
|
c.Err = model.NewAppError("updateChannel", "You do not have the appropriate permissions ", "")
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ func (c *Context) IsTeamAdmin(userId string) bool {
|
|||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
user := uresult.Data.(*model.User)
|
user := uresult.Data.(*model.User)
|
||||||
return model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) && user.TeamId == c.Session.TeamId
|
return model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) && user.TeamId == c.Session.TeamId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if post.UserId != c.Session.UserId && !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) {
|
if post.UserId != c.Session.UserId && !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
c.Err = model.NewAppError("deletePost", "You do not have the appropriate permissions", "")
|
c.Err = model.NewAppError("deletePost", "You do not have the appropriate permissions", "")
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ func InviteMembers(c *Context, team *model.Team, user *model.User, invites []str
|
|||||||
sender := user.GetDisplayName()
|
sender := user.GetDisplayName()
|
||||||
|
|
||||||
senderRole := ""
|
senderRole := ""
|
||||||
if model.IsInRole(user.Roles, model.ROLE_ADMIN) || model.IsInRole(user.Roles, model.ROLE_SYSTEM_ADMIN) {
|
if model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) || model.IsInRole(user.Roles, model.ROLE_SYSTEM_ADMIN) {
|
||||||
senderRole = "administrator"
|
senderRole = "administrator"
|
||||||
} else {
|
} else {
|
||||||
senderRole = "member"
|
senderRole = "member"
|
||||||
@@ -536,7 +536,7 @@ func updateTeamDisplayName(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) {
|
if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
c.Err = model.NewAppError("updateTeamDisplayName", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
|
c.Err = model.NewAppError("updateTeamDisplayName", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
@@ -576,7 +576,7 @@ func updateValetFeature(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) {
|
if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
c.Err = model.NewAppError("updateValetFeature", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
|
c.Err = model.NewAppError("updateValetFeature", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
|
|||||||
14
api/user.go
14
api/user.go
@@ -170,7 +170,7 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User {
|
|||||||
|
|
||||||
channelRole := ""
|
channelRole := ""
|
||||||
if team.Email == user.Email {
|
if team.Email == user.Email {
|
||||||
user.Roles = model.ROLE_ADMIN
|
user.Roles = model.ROLE_TEAM_ADMIN
|
||||||
channelRole = model.CHANNEL_ROLE_ADMIN
|
channelRole = model.CHANNEL_ROLE_ADMIN
|
||||||
} else {
|
} else {
|
||||||
user.Roles = ""
|
user.Roles = ""
|
||||||
@@ -945,7 +945,7 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) && !c.IsSystemAdmin() {
|
if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) && !c.IsSystemAdmin() {
|
||||||
c.Err = model.NewAppError("updateRoles", "You do not have the appropriate permissions", "userId="+user_id)
|
c.Err = model.NewAppError("updateRoles", "You do not have the appropriate permissions", "userId="+user_id)
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
@@ -984,7 +984,7 @@ func UpdateRoles(c *Context, user *model.User, roles string) *model.User {
|
|||||||
// make sure there is at least 1 other active admin
|
// make sure there is at least 1 other active admin
|
||||||
|
|
||||||
if !model.IsInRole(roles, model.ROLE_SYSTEM_ADMIN) {
|
if !model.IsInRole(roles, model.ROLE_SYSTEM_ADMIN) {
|
||||||
if model.IsInRole(user.Roles, model.ROLE_ADMIN) && !model.IsInRole(roles, model.ROLE_ADMIN) {
|
if model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) && !model.IsInRole(roles, model.ROLE_TEAM_ADMIN) {
|
||||||
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
||||||
c.Err = result.Err
|
c.Err = result.Err
|
||||||
return nil
|
return nil
|
||||||
@@ -992,7 +992,7 @@ func UpdateRoles(c *Context, user *model.User, roles string) *model.User {
|
|||||||
activeAdmins := -1
|
activeAdmins := -1
|
||||||
profileUsers := result.Data.(map[string]*model.User)
|
profileUsers := result.Data.(map[string]*model.User)
|
||||||
for _, profileUser := range profileUsers {
|
for _, profileUser := range profileUsers {
|
||||||
if profileUser.DeleteAt == 0 && model.IsInRole(profileUser.Roles, model.ROLE_ADMIN) {
|
if profileUser.DeleteAt == 0 && model.IsInRole(profileUser.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
activeAdmins = activeAdmins + 1
|
activeAdmins = activeAdmins + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1042,14 +1042,14 @@ func updateActive(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) && !c.IsSystemAdmin() {
|
if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) && !c.IsSystemAdmin() {
|
||||||
c.Err = model.NewAppError("updateActive", "You do not have the appropriate permissions", "userId="+user_id)
|
c.Err = model.NewAppError("updateActive", "You do not have the appropriate permissions", "userId="+user_id)
|
||||||
c.Err.StatusCode = http.StatusForbidden
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure there is at least 1 other active admin
|
// make sure there is at least 1 other active admin
|
||||||
if !active && model.IsInRole(user.Roles, model.ROLE_ADMIN) {
|
if !active && model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
||||||
c.Err = result.Err
|
c.Err = result.Err
|
||||||
return
|
return
|
||||||
@@ -1057,7 +1057,7 @@ func updateActive(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
activeAdmins := -1
|
activeAdmins := -1
|
||||||
profileUsers := result.Data.(map[string]*model.User)
|
profileUsers := result.Data.(map[string]*model.User)
|
||||||
for _, profileUser := range profileUsers {
|
for _, profileUser := range profileUsers {
|
||||||
if profileUser.DeleteAt == 0 && model.IsInRole(profileUser.Roles, model.ROLE_ADMIN) {
|
if profileUser.DeleteAt == 0 && model.IsInRole(profileUser.Roles, model.ROLE_TEAM_ADMIN) {
|
||||||
activeAdmins = activeAdmins + 1
|
activeAdmins = activeAdmins + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ func TestUserUpdate(t *testing.T) {
|
|||||||
user.TeamId = "12345678901234567890123456"
|
user.TeamId = "12345678901234567890123456"
|
||||||
user.LastActivityAt = time2
|
user.LastActivityAt = time2
|
||||||
user.LastPingAt = time2
|
user.LastPingAt = time2
|
||||||
user.Roles = model.ROLE_ADMIN
|
user.Roles = model.ROLE_TEAM_ADMIN
|
||||||
user.LastPasswordUpdate = 123
|
user.LastPasswordUpdate = 123
|
||||||
|
|
||||||
if result, err := Client.UpdateUser(user); err != nil {
|
if result, err := Client.UpdateUser(user); err != nil {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ROLE_ADMIN = "admin"
|
ROLE_TEAM_ADMIN = "admin"
|
||||||
ROLE_SYSTEM_ADMIN = "system_admin"
|
ROLE_SYSTEM_ADMIN = "system_admin"
|
||||||
USER_AWAY_TIMEOUT = 5 * 60 * 1000 // 5 minutes
|
USER_AWAY_TIMEOUT = 5 * 60 * 1000 // 5 minutes
|
||||||
USER_OFFLINE_TIMEOUT = 1 * 60 * 1000 // 1 minute
|
USER_OFFLINE_TIMEOUT = 1 * 60 * 1000 // 1 minute
|
||||||
@@ -289,7 +289,7 @@ func isValidRole(role string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if role == ROLE_ADMIN {
|
if role == ROLE_TEAM_ADMIN {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user