示例#1
0
        public async Task <bool> IsPermitted(int userId, params RoleType[] roleTypes)
        {
            if (Configuration.IsDev(userId))
            {
                return(true);
            }

            var query = RolesServiceUtils.BuildIsPermittedQuery(userId, roleTypes);

            var result = await database.SelectQueryFirst <IsPermittedResult>(query)
                         ?? throw new DatabaseException();

            return(result.IsPermitted);
        }
示例#2
0
        public async Task <bool> IsPermitted(User user, params RoleType[] roleTypes)
        {
            if (user == null)
            {
                throw new EntityNotFoundException("User not found");
            }

            if (Configuration.IsDev(user.Id))
            {
                return(true);
            }

            var query = RolesServiceUtils.BuildIsPermittedQuery(user.Id, roleTypes);

            var result = await database.SelectQueryFirst <IsPermittedResult>(query)
                         ?? throw new DatabaseException();

            return(result.IsPermitted);
        }