/// <summary> /// This returns true if the current user has the permission /// </summary> /// <param name="user"></param> /// <param name="permission"></param> /// <returns></returns> public static bool AEAAUserHasThisPermission(this ClaimsPrincipal user, AEAAPermissions permission) { var permissionClaim = user?.Claims.SingleOrDefault(x => x.Type == PermissionConstants.PackedPermissionClaimType); return(permissionClaim?.Value.UnpackPermissionsFromString().ToArray().UserHasThisPermission(permission) == true); }
public PermissionDisplay(string groupName, string name, string description, AEAAPermissions permission /*string moduleName*/) { Permission = permission; GroupName = groupName; ShortName = name ?? throw new ArgumentNullException(nameof(name)); Description = description ?? throw new ArgumentNullException(nameof(description)); //ModuleName = moduleName; }
/// <summary> /// This is the main checker of whether a user permissions allows them to access something with the given permission /// </summary> /// <param name="usersPermissions"></param> /// <param name="permissionToCheck"></param> /// <returns></returns> public static bool UserHasThisPermission(this AEAAPermissions[] usersPermissions, AEAAPermissions permissionToCheck) { return(usersPermissions.Contains(permissionToCheck) || usersPermissions.Contains(AEAAPermissions.AccessAll)); }
public HasPermissionAttribute(AEAAPermissions permission) : base(permission.ToString()) { }