/// <summary> /// Gets an enumeration of Permissions that are assigned to the given user through its roles /// </summary> /// <param name="user">the user for which to get the permissions</param> /// <returns>an enumerable of permissions for the given user</returns> public IEnumerable <Permission> GetPermissions(User user) { using var tmp = new FullSecurityAccessHelper(securityContext, false, false); return((from p in (from r in AllRoles(securityContext.Users.First(UserFilter(user))) select r.Role.RolePermissions).SelectMany(rp => rp) select new Permission { //PermissionName = $"{(!p.Permission.IsGlobal?p.Tenant.TenantName:"")}{p.Permission.PermissionName}" PermissionName = p.Permission.PermissionName }).Distinct().ToArray()); }
protected abstract System.Linq.Expressions.Expression <Func <TUser, bool> > UserFilter(User user);
/// <summary> /// Gets an enumeration of CustomUserProperties for the given user /// </summary> /// <param name="user">the user for which to get the custom properties</param> /// <returns>an enumerable of all the custom user-properties for this user</returns> public IEnumerable <CustomUserProperty> GetCustomProperties(User user) { using var tmp = new FullSecurityAccessHelper(securityContext, false, false); return((from p in UserProps(securityContext.Users.First(UserFilter(user))) select p).ToArray()); }
/// <summary> /// Gets an enumeration of Roles that are assigned to the given user /// </summary> /// <param name="user">the user for which to get the roles</param> /// <returns>an enumerable of all the user-roles</returns> public IEnumerable <Role> GetRoles(User user) { using var tmp = new FullSecurityAccessHelper(securityContext, false, false); return((from r in AllRoles(securityContext.Users.First(UserFilter(user))) select r.Role).ToArray()); }