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); }
public void ChangePassword(ChangePassword password, Action <ChangePasswordState> changePasswordResponse) { _changePasswordResponse = changePasswordResponse; if (!ValidateHelper.CheckPassword(password.NewPassword)) { ChangePasswordResponse(ChangePasswordState.InvalidNewPassword); return; } var future = Global.SendToServer(password, MessageType.ChangePasswordRequest); if (future == null) { ChangePasswordResponse(ChangePasswordState.CannotConnectServer); } }
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); }
public void CheckPassword_ShouldNotWork(string username) { ValidateHelper validateHelper = new ValidateHelper(null); //var expected = true; var actual = validateHelper.CheckPassword(username); Assert.False(actual); var List = new List <UserModel> { new UserModel { Email = "sdad" }, new UserModel { Email = "dada" } }; }
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); } }