diff --git a/packages/httpRequest/hubs.go b/packages/httpRequest/hubs.go index e18ebb4..655379c 100644 --- a/packages/httpRequest/hubs.go +++ b/packages/httpRequest/hubs.go @@ -488,3 +488,30 @@ func HandleHubSelfRoleRemove(response http.ResponseWriter, request *http.Request hubUser.Roles.Remove(roleId) response.WriteHeader(http.StatusAccepted) } + +func PermissionSetRoleName(response http.ResponseWriter, request *http.Request) { + _, hub, _, ok := hubPermissionContext(response, request, normal, types.PermissionSetRoleName) + if !ok { + return + } + roleId, err := convertions.StringToUint8(request.FormValue("roleid")) + if err != nil { + http.Error(response, "bad roleid", http.StatusBadRequest) + return + } + newName := request.FormValue("newname") + if newName == "" { + http.Error(response, "name empty", http.StatusBadRequest) + return + } + + hub.Mu.Lock() + role := hub.Roles[roleId] + if role == nil { + http.Error(response, "no such role", http.StatusNotFound) + return + } + role.Name = newName + hub.Mu.Unlock() + response.WriteHeader(http.StatusAccepted) +} diff --git a/packages/types/types.go b/packages/types/types.go index 291a5e0..04363cd 100644 --- a/packages/types/types.go +++ b/packages/types/types.go @@ -163,6 +163,7 @@ const ( PermissionRemoveRole PermissionSetRoleName PermissionSetRoleColor + PermissionSetRolePermissions PermissionSelfRoleRemove PermissionOnlySelfRoleRemove