Beispiel #1
0
 /// <summary>
 /// Check the authority is only avalilable in specified board. (This method only support unit authority)
 /// </summary>
 /// <param name="authority">System authority</param>
 /// <returns>Avalilable or not</returns>
 private bool InnerBoardAuthority(SystemAuthority authority)
 {
     return(authority == SystemAuthority.ThreadArchive ||
            authority == SystemAuthority.ThreadStop ||
            authority == SystemAuthority.EditResponse ||
            authority == SystemAuthority.ViewResponseDetail ||
            authority == SystemAuthority.BoardSetting ||
            authority == SystemAuthority.RemoveResponse ||
            authority == SystemAuthority.AboneResponse);
 }
Beispiel #2
0
 public bool HasSystemAuthority(SystemAuthority authority, string boardKey = null)
 {
     // authority_map.png
     if ((SystemAuthority & SystemAuthority.Owner)
         == SystemAuthority.Owner)
     {
         return(true);
     }
     if ((SystemAuthority & SystemAuthority.Admin)
         == SystemAuthority.Admin && authority != SystemAuthority.Owner)
     {
         return(true);
     }
     if ((SystemAuthority & SystemAuthority.BoardsManagement)
         == SystemAuthority.BoardsManagement)
     {
         if (InnerBoardAuthority(authority) ||
             authority == SystemAuthority.BoardsManagement)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     if ((SystemAuthority & SystemAuthority.RemoveResponse) == SystemAuthority.RemoveResponse)
     {
         if (authority == SystemAuthority.AboneResponse ||
             authority == SystemAuthority.RemoveResponse)
         {
             if (!string.IsNullOrEmpty(boardKey))
             {
                 return(ControllableBoards?.Any(x => x == boardKey) ?? false);
             }
         }
     }
     if ((SystemAuthority & SystemAuthority.CapUserSetting) == SystemAuthority.CapUserSetting &&
         authority == SystemAuthority.CapUserSetting)
     {
         return(true);
     }
     if (InnerBoardAuthority(authority) &&
         !string.IsNullOrEmpty(boardKey) &&
         ((SystemAuthority & authority) == authority || (SystemAuthority & SystemAuthority.BoardSetting) == SystemAuthority.BoardSetting))
     {
         return(ControllableBoards?.Any(x => x == boardKey) ?? false);
     }
     return(false);
 }
        protected async Task <bool> HasSystemAuthority(SystemAuthority authority, string boardKey = null)
        {
            await GetSessionUserAsync();

            return(CurrentUser?.HasSystemAuthority(authority, boardKey) ?? false);
        }