Example #1
0
        public ChangePasswordState ChangePassword(ChangePassword password)
        {
            if (!ValidateHelper.CheckPassword(password.NewPassword))
            {
                return(ChangePasswordState.InvalidNewPassword);
            }

            var user = _userDal.Get(password.Id);

            if (user == null)
            {
                return(ChangePasswordState.InvalidOpt);
            }

            if (!PasswordEncrypt.CheckPassword(password.OldPassword, user.Salt, user.Password))
            {
                return(ChangePasswordState.InvalidOldPassword);
            }

            if (!_userDal.UpdatePassword(password.Id,
                                         PasswordEncrypt.GetEncryptPassword(password.NewPassword, user.Salt)))
            {
                return(ChangePasswordState.Failed);
            }

            return(ChangePasswordState.Successed);
        }
Example #2
0
        public bool ChangePassword(int userId, string password, string salt)
        {
            const string sql = @"
                UPDATE  [User]
                SET     [Password] = @Password
                WHERE   Id = @Id";

            password = PasswordEncrypt.GetEncryptPassword(password, salt);
            using (var con = DbFactory.Instance.CreateConnection())
            {
                return(con.Execute(sql, new User
                {
                    Id = userId,
                    Password = password
                }) > 0);
            }
        }
Example #3
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 #4
0
 public void Password()
 {
     var pwd = PasswordEncrypt.GetEncryptPassword("888888", "6223171d");
     var ss  = pwd;
 }