Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userKey"></param>
        /// <param name="password"></param>
        /// <param name="userPassport"></param>
        /// <returns></returns>
        public static bool SignIn(string userKey, string password, out UserPassport userPassport)
        {
            ArgumentAssertion.IsNotNull(userKey, "userKey");
            ArgumentAssertion.IsNotNull(password, "password");

            long passportId = 0;

            if (userKey.IsMatchEMail())
            {
                passportId = UserPassport.FindIdByEmail(userKey);
            }
            else if (userKey.IsMatchMobilePhone())
            {
                passportId = UserPassport.FindIdByMobilePhone(userKey);
            }
            else
            {
                passportId = UserPassport.FindIdByUserName(userKey);
            }

            userPassport = null;
            var verified = false;

            if (passportId > 0)
            {
                UserPassport passport = null;
                verified = VerifyPassword(passportId, password, out passport);
                if (verified)
                {
                    userPassport = passport;
                    userPassport.SignIn();

                    if (null != OnSignIn)
                    {
                        OnSignIn(userPassport);
                    }
                }
            }
            return(verified);
        }
Пример #2
0
        private static SignStatus CheckUserName(string userName)
        {
            var signUpStatus = SignStatus.None;

            if (string.IsNullOrEmpty(userName))
            {
                return(signUpStatus);
            }
            if (false == Regex.IsMatch(userName, ModuleEnvironment.UserNamePattern))
            {
                signUpStatus = SignStatus.InvalidUserName;
            }
            else
            {
                var passportId = UserPassport.FindIdByUserName(userName);
                if (passportId > 0)
                {
                    signUpStatus = SignStatus.DuplicateUserName;
                }
            }

            return(signUpStatus);
        }