예제 #1
0
        public Response ChangeRights([FromBody] PermissionModel permissionModel)
        {
            Response reqResponse = new Response();

            if (permissionModel.username != "root")
            {
                reqResponse.SetResponse(401, "Not Authorized", "You are not authorized to change the rights of the selected permission!", null);
                goto Finish;
            }

            int userId = _userService.GetUser(permissionModel.username, permissionModel.password);

            if (userId == -1)
            {
                reqResponse.SetResponse(401, "Not Authorized", "Invalid credentials inserted!", null);
                goto Finish;
            }

            if (!_permissionService.ExistsPermission(permissionModel.permissionName))
            {
                reqResponse.SetResponse(500, "Not Existing", "Permission '" + permissionModel.permissionName + "' does not exist in the system.", null);
                goto Finish;
            }

            _permissionService.ChangeRights(permissionModel.permissionName, permissionModel.rights);
            reqResponse = new Response();

Finish:
            return(reqResponse);
        }