Esempio n. 1
0
        public override async Task <TResult> Handle(TQuery query)
        {
            if (_rootProcessRegistrator.IsRootProcess(query))
            {
                var rights = query.GetType().GetCustomAttributes <Kiss4RightAttribute>();
                if (!await _authorizationChecker.UserHasRights(rights))
                {
                    throw new UnauthorizedAccessException(string.Format(AuthorizationResources.Unauthorized, query.GetType().Name));
                }
            }

            return(await _decorated.Handle(query));
        }
        public override async Task Handle(TCommand command)
        {
            if (_rootProcessRegistrator.IsRootProcess(command))
            {
                var rights = command.GetType().GetCustomAttributes <Kiss4RightAttribute>();
                if (!await _authorizationChecker.UserHasRights(rights))
                {
                    throw new UnauthorizedAccessException(string.Format(AuthorizationResources.Unauthorized, command.GetType().Name));
                }
            }

            await _decorated.Handle(command);
        }