Example #1
0
        public override Task <CheckPermissionResponse> CheckPermission(CheckPermissionRequest request, ServerCallContext context)
        {
            this.Logger.LogInformation($"Operation:{Utils.GetActualAsyncMethodName()} Payload:{Utils.ProtoToJson(request)}");
            var response = new CheckPermissionResponse()
            {
                Status = 0
            };

            try
            {
                var result = AuthorizationManager.Instance.CheckPermission(
                    request.CurrentUser.Name,
                    request.User.Name,
                    request.ResourceType,
                    new Guid(request.ResourceId),
                    request.Permission);
                response.HasPermission = result;
            }
            catch (Exception e)
            {
                response.Status  = 1;
                response.Message = e.Message;
            }

            return(Task.FromResult(response));
        }
Example #2
0
        public static CheckPermissionResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CheckPermissionResponse checkPermissionResponse = new CheckPermissionResponse();

            checkPermissionResponse.HttpResponse = _ctx.HttpResponse;
            checkPermissionResponse.RequestId    = _ctx.StringValue("CheckPermission.RequestId");
            checkPermissionResponse.Success      = _ctx.BooleanValue("CheckPermission.Success");
            checkPermissionResponse.ErrMessage   = _ctx.StringValue("CheckPermission.ErrMessage");

            return(checkPermissionResponse);
        }