コード例 #1
0
        public async Task <bool> HasAllRolesAsync(IRequest req, IAuthSession session, IAuthRepositoryAsync authRepo)
        {
            if (await SessionValidForAllRolesAsync(req, session, RequiredRoles).ConfigAwait())
            {
                return(true);
            }

            return(await session.HasAllRolesAsync(RequiredRoles, authRepo, req).ConfigAwait());
        }
コード例 #2
0
        public static async Task <bool> HasAllRolesAsync(IRequest req, IAuthSession session, ICollection <string> requiredRoles, CancellationToken token = default)
        {
            if (await SessionValidForAllRolesAsync(req, session, requiredRoles))
            {
                return(true);
            }

            var authRepo = HostContext.AppHost.GetAuthRepositoryAsync(req);

            await using (authRepo as IAsyncDisposable)
            {
                return(await session.HasAllRolesAsync(requiredRoles, authRepo, req, token).ConfigAwait());
            }
        }