示例#1
0
        public static LoginUserStatus ValidateUser(HiMembershipUser user)
        {
            LoginUserStatus result;

            if (user == null)
            {
                result = LoginUserStatus.UnknownError;
            }
            else
            {
                if (!user.IsApproved)
                {
                    result = LoginUserStatus.AccountPending;
                }
                else
                {
                    if (user.IsLockedOut)
                    {
                        result = LoginUserStatus.AccountLockedOut;
                    }
                    else
                    {
                        if (!HiMembership.ValidateUser(user.Username, user.Password))
                        {
                            result = LoginUserStatus.InvalidCredentials;
                        }
                        else
                        {
                            result = LoginUserStatus.Success;
                        }
                    }
                }
            }
            return(result);
        }
示例#2
0
        public static MembershipUser Create(string username, string password, string email)
        {
            MembershipUser   membershipUser   = null;
            CreateUserStatus createUserStatus = CreateUserStatus.UnknownFailure;

            try
            {
                if (!string.IsNullOrEmpty(email))
                {
                    membershipUser   = System.Web.Security.Membership.CreateUser(username, password, email);
                    createUserStatus = ((membershipUser == null) ? CreateUserStatus.UnknownFailure : CreateUserStatus.Created);
                }
                else
                {
                    membershipUser   = System.Web.Security.Membership.CreateUser(username, password);
                    createUserStatus = ((membershipUser == null) ? CreateUserStatus.UnknownFailure : CreateUserStatus.Created);
                }
            }
            catch (MembershipCreateUserException ex)
            {
                createUserStatus = HiMembership.GetCreateUserStatus(ex.StatusCode);
            }
            catch (Exception exception_)
            {
                createUserStatus = HiMembership.GetCreateUserStatus(exception_);
            }
            if (createUserStatus != CreateUserStatus.Created)
            {
                throw new CreateUserException(createUserStatus);
            }
            return(membershipUser);
        }
示例#3
0
        public static CreateUserStatus GetCreateUserStatus(Exception exception_0)
        {
            MembershipCreateUserException ex = exception_0 as MembershipCreateUserException;
            CreateUserStatus result;

            if (ex != null)
            {
                result = HiMembership.GetCreateUserStatus(ex.StatusCode);
            }
            else
            {
                result = CreateUserStatus.UnknownFailure;
            }
            return(result);
        }
示例#4
0
 public static LoginUserStatus ValidateUser(HiMembershipUser user)
 {
     if (user == null)
     {
         return(LoginUserStatus.UnknownError);
     }
     if (!user.IsApproved)
     {
         return(LoginUserStatus.AccountPending);
     }
     if (user.IsLockedOut)
     {
         return(LoginUserStatus.AccountLockedOut);
     }
     if (!HiMembership.ValidateUser(user.Username, user.Password))
     {
         return(LoginUserStatus.InvalidCredentials);
     }
     return(LoginUserStatus.Success);
 }
示例#5
0
 public static MembershipUser GetUser(string username)
 {
     return(HiMembership.GetUser(username, false));
 }
示例#6
0
 public static MembershipUser GetUser(object userId)
 {
     return(HiMembership.GetUser(userId, false));
 }