Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 /// <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));
 }
Esempio n. 4
0
 public HasPermissionAttribute(AEAAPermissions permission) : base(permission.ToString())
 {
 }