/// <summary>
        /// Deletes an existing role in a group.
        /// </summary>
        public static void DeleteRole(DeleteRoleRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;


            PlayFabHttp.MakeApiCall("/Group/DeleteRole", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context);
        }
        public async Task <IActionResult> DeleteRole([FromBody] DeleteRoleRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Ok(ModelState));
            }

            bool            isExist = !String.IsNullOrEmpty(model.RoleName);
            IdentityResult  roleResult;
            ApplicationRole applicationRole = await _roleservice.FindByNameAsync(model.RoleName);

            if (ModelState.IsValid)
            {
                if (isExist && _roleservice.FindByNameAsync(model.RoleName) != null)
                {
                    roleResult = _roleservice.DeleteAsync(applicationRole).Result;
                    if (roleResult.Succeeded)
                    {
                        return(Ok("Role SuccessFully Deleted...."));
                    }
                    else
                    {
                        return(Ok("Failed To Delete Role...."));
                    }
                }
            }
            return(Ok("UnExpected Eroor!!!!"));
        }
예제 #3
0
        /// <summary>
        /// Clean up all test resources.
        /// Also cleans up any resources that might be left from previous failed/interrupted tests.
        /// </summary>
        /// <param name="s3Client"></param>
        /// <param name="lambdaClient"></param>
        /// <returns></returns>
        private async Task CleanUpTestResources(AmazonS3Client s3Client, AmazonLambdaClient lambdaClient,
                                                AmazonIdentityManagementServiceClient iamClient, bool roleAlreadyExisted)
        {
            await DeleteFunctionIfExistsAsync(lambdaClient);

            var listBucketsResponse = await s3Client.ListBucketsAsync();

            foreach (var bucket in listBucketsResponse.Buckets)
            {
                if (bucket.BucketName.StartsWith(TestBucketRoot))
                {
                    await DeleteDeploymentZipAndBucketAsync(s3Client, bucket.BucketName);
                }
            }

            if (!roleAlreadyExisted)
            {
                try
                {
                    var deleteRoleRequest = new DeleteRoleRequest
                    {
                        RoleName = ExecutionRoleName
                    };
                    await iamClient.DeleteRoleAsync(deleteRoleRequest);
                }
                catch (Exception)
                {
                    // no problem - it's best effort
                }
            }
        }
예제 #4
0
        public IActionResult DeleteRole([FromBody] DeleteRoleRequest request)
        {
            var client = GetRoleClient();

            client.DeleteRole(request.RoleId);
            return(AjaxOkResponse());
        }
예제 #5
0
        private static void DeleteRole(String RoleName)
        {
            if (String.IsNullOrEmpty(Token))
            {
                stsClient = new AmazonIdentityManagementServiceClient(AccessKeyId, SecretKey, iamconfig);
            }
            else
            {
                stsClient = new AmazonIdentityManagementServiceClient(AccessKeyId, SecretKey, Token, iamconfig);
            }

            DeleteRoleRequest Req = new DeleteRoleRequest();

            Req.RoleName = RoleName;

            try
            {
                DeleteRoleResponse response = stsClient.DeleteRole(Req);
                Console.WriteLine("Role Deleted");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occured while creating user. " + ex.ToString());
            }
        }
예제 #6
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool DeleteRole(DeleteRoleRequest request)
        {
            //删除角色数据
            //删除用户角色数据
            //删除角色菜单按钮数据
            //使用事务
            var result = false;

            using (var conn = DapperHelper.CreateConnection())
            {
                var trans = conn.BeginTransaction();

                try
                {
                    //删除角色
                    conn.Execute(@"DELETE FROM dbo.t_rights_role WHERE id= @RoleId;", new { @RoleId = request.DeleteRoleId }, trans);

                    //删除用户角色
                    conn.Execute(@"DELETE FROM dbo.t_rights_user_role WHERE role_id= @RoleId;", new { @RoleId = request.DeleteRoleId }, trans);

                    //删除角色菜单按钮
                    conn.Execute(@"DELETE FROM dbo.t_rights_role_menu_button WHERE role_id= @RoleId;", new { @RoleId = request.DeleteRoleId }, trans);

                    trans.Commit();
                    result = true;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }
            }

            return(result);
        }
        /// <summary>
        /// Deletes an existing role in a group.
        /// </summary>
        public static async Task <PlayFabResult <EmptyResponse> > DeleteRoleAsync(DeleteRoleRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            if ((request?.AuthenticationContext?.EntityToken ?? PlayFabSettings.staticPlayer.EntityToken) == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call GetEntityToken before calling this method");
            }


            var httpResult = await PlayFabHttp.DoPost("/Group/DeleteRole", request, "X-EntityToken", PlayFabSettings.staticPlayer.EntityToken, extraHeaders);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <EmptyResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <EmptyResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <EmptyResponse> {
                Result = result, CustomData = customData
            });
        }
예제 #8
0
        public override async Task <DeleteRoleResponse> DeleteRole(DeleteRoleRequest request, ServerCallContext context)
        {
            if (!await _roleService.RoleExistsAsync(request.RoleName))
            {
                throw context.NotFoundRpcException($"The role '{request.RoleName}' wasn't found.");
            }

            var role = await _roleService.FindByNameAsync(request.RoleName);

            var result = await _roleService.DeleteAsync(role);

            if (result.Succeeded)
            {
                var detail = $"The role '{role.Name}' as been deleted. (roleId=${role.Id})";

                var response = new DeleteRoleResponse
                {
                    Role = new RoleDto
                    {
                        Id   = role.Id.ToString(),
                        Name = role.Name
                    }
                };

                return(context.Ok(response, detail));
            }

            throw context.FailedPreconditionRpcException(result, $"Failed to delete the role '{role.Name}'. (roleId=${role.Id})");
        }
예제 #9
0
        public async Task <IActionResult> DeleteRoleAsync([FromRoute] Guid id)
        {
            var request = new DeleteRoleRequest
            {
                Id = id,
            };
            var response = await _authorizationClient.DeleteRoleAsync(request);

            return(NoContent());
        }
예제 #10
0
        public DeleteRoleResponse Delete(DeleteRoleRequest request)
        {
            unitOfWork.BeginTransaction();
            var role = roleService.DeleteRole(request.Id, request.Data.Version, true);
            unitOfWork.Commit();

            // Notify.
            Events.UserEvents.Instance.OnRoleDeleted(role);

            return new DeleteRoleResponse { Data = true };
        }
        /// <summary>
        /// Deletes an existing role in a group.
        /// </summary>
        public void DeleteRole(DeleteRoleRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context      = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
            var callSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (!context.IsEntityLoggedIn())
            {
                throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method");
            }
            PlayFabHttp.MakeApiCall("/Group/DeleteRole", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
        }
예제 #12
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgvList.CurrentRow == null) SOAFramework.Client.Controls.MessageBox.Show(this, "请选择一条数据");
     else if (SOAFramework.Client.Controls.MessageBox.Show(this,"是否删除选中的数据?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         var role = dgvList.CurrentRow.DataBoundItem as FullRoleInfo;
         DeleteRoleRequest request = new DeleteRoleRequest();
         request.token = Token;
         request.RoleID = role.ID;
         SDKSync<CommonResponse>.CreateInstance(this).Execute(request, Delete_Callback);
     }
 }
예제 #13
0
        public async Task <Response <string> > DeleteRoleAsync(DeleteRoleRequest request)
        {
            var role = await _roleManager.FindByIdAsync(request.Id);

            if (role == null)
            {
                throw new ApiException("not found id");
            }
            await _roleManager.DeleteAsync(role);

            return(new Response <string>(role.Id));
        }
예제 #14
0
        public DeleteRoleResponse Delete(DeleteRoleRequest request)
        {
            unitOfWork.BeginTransaction();
            var role = roleService.DeleteRole(request.Id, request.Data.Version, true);

            unitOfWork.Commit();

            // Notify.
            Events.UserEvents.Instance.OnRoleDeleted(role);

            return(new DeleteRoleResponse {
                Data = true
            });
        }
예제 #15
0
        public async Task <bool> Handle(DeleteRoleRequest request, CancellationToken cancellationToken)
        {
            var role = context.Roles.FirstOrDefault(u => u.Id == request.Id);

            if (role == null)
            {
                return(false);
            }

            context.Roles.Remove(role);
            await context.SaveChangesAsync();

            return(true);
        }
예제 #16
0
        /// <summary>
        /// Deletes an existing role in a group.
        /// </summary>
        /// <param name="Group">The identifier of the group (Required)</param>
        /// <param name="RoleId">The ID of the role to delete. Role IDs must be between 1 and 64 characters long. (Optional)</param>
        public static Task <EmptyResponse> DeleteRole(EntityKey Group, string RoleId = default,
                                                      PlayFabAuthenticationContext customAuthContext = null, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            DeleteRoleRequest request = new DeleteRoleRequest()
            {
                Group  = Group,
                RoleId = RoleId,
            };

            var context = GetContext(customAuthContext);

            return(PlayFabHttp.MakeApiCallAsync <EmptyResponse>("/Group/DeleteRole", request,
                                                                AuthType.EntityToken,
                                                                customData, extraHeaders, context));
        }
        /// <summary>
        /// 本接口(DeleteRole)用于删除指定角色。
        /// </summary>
        /// <param name="req">参考<see cref="DeleteRoleRequest"/></param>
        /// <returns>参考<see cref="DeleteRoleResponse"/>实例</returns>
        public async Task <DeleteRoleResponse> DeleteRole(DeleteRoleRequest req)
        {
            JsonResponseModel <DeleteRoleResponse> rsp = null;

            try
            {
                var strResp = await this.InternalRequest(req, "DeleteRole");

                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteRoleResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
예제 #18
0
 public SuccessResponse Delete(DeleteRoleRequest request)
 {
     try
     {
         var role = _roleRepository.FindBy(request.Id);
         role.ThrowExceptionIfRecordIsNull();
         _roleValidator.ValidateAndThrowException(role, "Base");
         var isReference = _roleRepository.IsReference(request.Id);
         isReference.ThrowExceptionIfIsReference();
         _roleRepository.Remove(role);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
예제 #19
0
        public ActionResult Delete(DeleteRoleRequest request)
        {
            var flag = false;
            var msg  = string.Empty;

            var rs = _roleService.DeleteRole(request);

            if (rs.ReturnCode == ReturnCodeType.Success && rs.Content == true)
            {
                flag = true;
                msg  = "删除成功!";
            }
            else
            {
                msg = rs.Message.IsNullOrEmpty() ? "删除失败!" : rs.Message;
            }

            return(Json(new { success = flag, msg = msg }, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        public async override Task <Task> Handle(DeleteRoleCommand command, CancellationToken cancellationToken = default)
        {
            using var client = _awsClientFactory.Create <AmazonIdentityManagementServiceClient>(command.AssumeProfile);

            var request = new DeleteRoleRequest()
            {
                RoleName = command.RoleName
            };

            try
            {
                await client.DeleteRoleAsync(request, cancellationToken);
            }
            catch (AmazonServiceException e)
            {
                throw new Exception(e.Message, e);
            }

            return(Task.CompletedTask);
        }
예제 #21
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ServiceResult <bool> DeleteRole(DeleteRoleRequest request)
        {
            //删除角色数据
            //删除用户角色数据
            //删除角色菜单按钮数据
            //使用事务
            var result = new ServiceResult <bool>
            {
                ReturnCode = ReturnCodeType.Error
            };

            var rs = _roleDao.DeleteRole(request);

            if (rs == true)
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = true;
            }

            return(result);
        }
예제 #22
0
        public ActionResult Delete(DeleteRoleRequest request)
        {
            var flag = false;
            var msg  = string.Empty;

            using (var factory = new ChannelFactory <IRightsRoleService>("*"))
            {
                var client = factory.CreateChannel();
                var rs     = client.DeleteRole(request);
                if (rs.ReturnCode == ReturnCodeType.Success && rs.Content == true)
                {
                    flag = true;
                    msg  = "删除成功!";
                }
                else
                {
                    msg = rs.Message.IsNullOrEmpty() ? "删除失败!" : rs.Message;
                }
            }

            return(Json(new { success = flag, msg = msg }, JsonRequestBehavior.AllowGet));
        }
예제 #23
0
        public DeleteRoleResponse DeleteRole(DeleteRoleRequest request)
        {
            DeleteRoleResponse response = new DeleteRoleResponse();

            Role role = _roleRepository.Get(request.Id);

            if (role == null)
            {
                response.HasError = true;
                return(response);
            }

            if (role.SystemRole)
            {
                response.SystemRole = true;
                return(response);
            }
            _roleRepository.Delete(role);
            _unitOfWork.Commit();

            return(response);
        }
예제 #24
0
        public async void TestAssumeRoleWithWebIdentityCredentialsUsesAnonymousAWSCredentialsToFetch()
        {
            var user = await Client.GetUserAsync().ConfigureAwait(false);

            var createRoleRequest = new CreateRoleRequest()
            {
                RoleName = "DummyAccountRole",
                AssumeRolePolicyDocument = "{\"Version\": \"2012-10-17\", \"Statement\": [{ \"Effect\": \"Allow\",\"Principal\": {\"AWS\": \"" + user.User.Arn + "\"},\"Action\": \"sts:AssumeRole\",\"Condition\": {}}]}"
            };
            var role = await Client.CreateRoleAsync(createRoleRequest).ConfigureAwait(false);

            var dummyToken               = "dummyToken";
            var dummyRoleArn             = role.Role.Arn;
            var dummyRoleSessionName     = "dummyRoleSessionName";
            var dummyOptions             = new AssumeRoleWithWebIdentityCredentialsOptions();
            var currentDirectory         = Directory.GetCurrentDirectory();
            var webIdentityTokenFilePath = Path.Combine(currentDirectory, "my-token.jwt");

            File.WriteAllText(webIdentityTokenFilePath, dummyToken);

            var webIdentityCredentials = new AssumeRoleWithWebIdentityCredentials(webIdentityTokenFilePath, dummyRoleArn, dummyRoleSessionName, dummyOptions);

            try
            {
                var fetchedCredentials = webIdentityCredentials.GetCredentials();
            }
            catch (AmazonClientException e)
            {
                Assert.Equal("InvalidIdentityToken", ((AmazonServiceException)e.InnerException).ErrorCode);
            }
            finally
            {
                var deleteRoleRequest = new DeleteRoleRequest()
                {
                    RoleName = role.Role.RoleName
                };
                await Client.DeleteRoleAsync(deleteRoleRequest);
            }
        }
예제 #25
0
 public bool Delete(string ID, string CreateUser, ref string msg, string ReasonDelete = null)
 {
     try
     {
         DeleteRoleRequest paraBody = new DeleteRoleRequest();
         paraBody.CreatedUser  = CreateUser;
         paraBody.ReasonDelete = ReasonDelete;
         paraBody.ID           = ID;
         //====================
         NSLog.Logger.Info("Permission Delete Request", paraBody);
         var result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.PermissionAPIDelete, null, paraBody);
         NSLog.Logger.Info("Permission Delete Response", paraBody);
         if (result != null)
         {
             if (result.Success)
             {
                 return(true);
             }
             else
             {
                 msg = result.Message;
                 NSLog.Logger.Info("PermissionDelete", result.Message);
                 return(false);
             }
         }
         else
         {
             NSLog.Logger.Info("PermissionDelete", result);
             return(false);
         }
     }
     catch (Exception e)
     {
         msg = e.ToString();
         NSLog.Logger.Error("PermissionDelete_Fail", e);
         return(false);
     }
 }
예제 #26
0
        public async Task <IActionResult> OnPostDeleteRoleAsync(DeleteRoleRequest request)
        {
            await SetUp();

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (!Member.Role.Privileges.Contains(Privilege.CanManageMembersAndRoles))
            {
                return(this.InsufficientPrivileges());
            }

            if (Members.Any(m => m.Role.Id == request.RoleId))
            {
                return(this.InsufficientPrivileges());
            }

            await _mediator.Send(_mapper.Map <DeleteRoleById>(request));

            return(RedirectToPage());
        }
 public Task <DeleteRoleResponse> DeleteRoleAsync(DeleteRoleRequest request, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new System.NotImplementedException();
 }
예제 #28
0
    public override async Task <Empty> DeleteRole(DeleteRoleRequest request, ServerCallContext context)
    {
        await _authorizationApp.DeleteRoleAsync(request.Id);

        return(new Empty());
    }
예제 #29
0
 public DeleteRoleResponse Delete(DeleteRoleRequest request)
 {
     throw new CmsException(UsersApiConstants.UsersApiHasNoImplementationMessage);
 }
예제 #30
0
 public Task <DeleteRoleResponse> DeleteRoleAsync(DeleteRoleRequest deleteRoleRequest)
 {
     throw new System.NotImplementedException();
 }
 public SuccessResponse Delete(DeleteRoleRequest request)
 {
     return(_roleService.Delete(request));
 }
예제 #32
0
 /// <summary>
 /// Deletes an existing role in a group.
 /// </summary>
 public static void DeleteRole(DeleteRoleRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
 {
     PlayFabHttp.MakeApiCall("/Group/DeleteRole", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders);
 }
예제 #33
0
 public Task <BaseResponse> DeleteRole(DeleteRoleRequest request, int UserID)
 {
     throw new NotImplementedException();
 }