Example #1
0
        public RegisterState Register(User user)
        {
            if (!ValidateHelper.CheckUserName(user.Account))
            {
                return(RegisterState.InvalidAccount);
            }

            if (!ValidateHelper.CheckPassword(user.Password))
            {
                return(RegisterState.InvalidPassword);
            }

            if (!ValidateHelper.CheckEmail(user.Email))
            {
                return(RegisterState.InvalidEmail);
            }

            if (!ValidateHelper.CheckQQ(user.QQ))
            {
                return(RegisterState.InvalidQQ);
            }

            if (!ValidateHelper.CheckMobile(user.Mobile))
            {
                return(RegisterState.InvalidMobile);
            }

            string salt;

            user.Password = PasswordEncrypt.GetEncryptPassword(user.Password, out salt);
            user.Salt     = salt;
            user.Account  = user.Account.ToLower();

            if (_userDal.Exists(user.Account))
            {
                return(RegisterState.AccountExists);
            }

            if (!_userDal.Add(user))
            {
                return(RegisterState.Failed);
            }

            return(RegisterState.Successed);
        }
Example #2
0
        public void Register(User user, Action <RegisterState> registerResponse)
        {
            _registerResponse = registerResponse;

            if (!ValidateHelper.CheckUserName(user.Account))
            {
                RegisterResponse(RegisterState.InvalidAccount);
                return;
            }

            if (!ValidateHelper.CheckPassword(user.Password))
            {
                RegisterResponse(RegisterState.InvalidPassword);
                return;
            }

            if (!ValidateHelper.CheckQQ(user.QQ))
            {
                RegisterResponse(RegisterState.InvalidQQ);
                return;
            }

            if (!ValidateHelper.CheckEmail(user.Email))
            {
                RegisterResponse(RegisterState.InvalidEmail);
                return;
            }

            if (!ValidateHelper.CheckMobile(user.Mobile))
            {
                RegisterResponse(RegisterState.InvalidMobile);
                return;
            }

            var future = Global.SendToServer(user, MessageType.RegisterRequest);

            if (future == null)
            {
                RegisterResponse(RegisterState.CannotConnectServer);
            }
        }