protected bool CheckUser()
        {
            UserManager userManager = UserManager.GetManager();
            RoleManager roleManager = RoleManager.GetManager(SecurityManager.ApplicationRolesProviderName);

            // Retrieve the current user
            SitefinityIdentity identity = ClaimsManager.GetCurrentIdentity();
            Guid currentUserId          = identity.UserId;

            // Checks whether the user exists and is an administrator
            if (currentUserId == Guid.Empty)
            {
                return(false);
            }
            User user         = userManager.GetUser(currentUserId);
            bool isUserInRole = roleManager.IsUserInRole(user.Id, "Administrators");

            if (!isUserInRole)
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
 public bool CheckIfUserIsModerator(SitefinityIdentity user)
 {
     return(user.Roles.Any(r => r.Name == Constants.ModeratorRole && r.Provider == Constants.ProviderOfRoles));
 }
Beispiel #3
0
 public bool CheckIfUserIsAuthenticated(SitefinityIdentity user)
 {
     return(user.IsAuthenticated);
 }