public static bool IsSystem(AVDUserIdentity userIdentity)
 {
     return Roles.IsUserInRole(RoleTypes.System.ToString());
 }
 public static bool IsAdminOrSuperUser(AVDUserIdentity userIdentity)
 {
     return (Roles.IsUserInRole(RoleTypes.Administrator.ToString()) || Roles.IsUserInRole(RoleTypes.SuperUser.ToString()));
 }
 public static bool IsRm(AVDUserIdentity userIdentity)
 {
     return userIdentity.AgencyId != null && Roles.IsUserInRole(RoleTypes.SuperAgent.ToString());
 }
 public static bool IsManager(AVDUserIdentity userIdentity)
 {
     return userIdentity.IsManager != null && (userIdentity.AgentId != null && userIdentity.IsManager.Value &&
                                               !Roles.IsUserInRole(RoleTypes.SuperAgent.ToString()));
 }
 public static bool IsEmployee(AVDUserIdentity userIdentity)
 {
     return userIdentity.IsEmployee != null && (userIdentity.AgentId != null && userIdentity.IsEmployee.Value && !IsManager(userIdentity) && !IsRm(userIdentity));
 }
Пример #6
0
        private static AVDIdentityBase GetAVDIdentity(String userName, bool isAuthenticated, String authenticationType)
        {
            Logger.Instance.LogFunctionEntry(typeof(AuthManager).Name, "GetAVDIdentity");

            AVDIdentityBase teIdentity;

            // Else it's a user that we store in our user tables. This will be either an Agent or Non-Agent.
            var membershipUser = Membership.GetUser(userName);

            if (membershipUser == null)
                throw new ApplicationException("User can not be found '" + userName);

            var userDto = membershipUser as UserDto;

            if (userDto == null)
                throw new ApplicationException("Can cast the MembershipUser into " + typeof (UserDto).Name);

            if (userDto.UserId <= 0)
                throw new ApplicationException("Invalid userDto - " + userDto);
          
            // Non-Agent User
            teIdentity = new AVDUserIdentity(userName, isAuthenticated, authenticationType, userDto.FirstName, userDto.LastName, userDto.Email, userDto.UserId,
                null, null, null, null, null);
            
            Logger.Instance.LogFunctionExit(typeof(AuthManager).Name, "GetAVDIdentity");

            return teIdentity;
        }