Ejemplo n.º 1
0
        public bool HasAllRoles(IRequest req, IAuthSession session, IAuthRepository authRepo)
        {
            if (SessionValidForAllRoles(req, session, RequiredRoles))
            {
                return(true);
            }

            return(session.HasAllRoles(RequiredRoles, authRepo, req));
        }
Ejemplo n.º 2
0
        public static Task <bool> HasAllRolesAsync(this IAuthSession session, ICollection <string> requiredRoles,
                                                   IAuthRepositoryAsync authRepo, IRequest req, CancellationToken token = default)
        {
            if (session is IAuthSessionExtended extended) // always true for sessions inheriting AuthUserSession
            {
                return(extended.HasAllRolesAsync(requiredRoles, authRepo, req, token));
            }

#pragma warning disable 618
            return(session.HasAllRoles(requiredRoles, (IAuthRepository)authRepo, req).InTask());

#pragma warning restore 618
        }
Ejemplo n.º 3
0
        public static bool HasAllRoles(IRequest req, IAuthSession session, ICollection <string> requiredRoles)
        {
            if (SessionValidForAllRoles(req, session, requiredRoles))
            {
                return(true);
            }

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

            using (authRepo as IDisposable)
            {
                return(session.HasAllRoles(requiredRoles, authRepo, req));
            }
        }