public int Step3(byte[] newPassword, string email) { if (CheckVendor.NotValidPassword(newPassword)) { return(03_0007); } if (CheckVendor.NotValidEmail(email)) { return(03_0005); } if (CheckVendor.NotValidResponse(_serverResponse)) { return(02_0008); } _password = newPassword; var recoveryRequest = new RecoveryRequest(); recoveryRequest.Email = email; recoveryRequest.Verifier = Srp6Vendor.Srp6Init(_username, _password, out var salt).ToByteArray(); recoveryRequest.Salt = salt; recoveryRequest.GroupParam = Srp6Vendor.BitLength; recoveryRequest.OperationToken = _serverResponse.AuthToken; recoveryRequest.ReportTime = DateTime.Now; var result = ApiCall.AuthReset.Call(null, new MilvanethProtocol { Context = null, Data = recoveryRequest }); if (!(result.Data is ServerResponse sr)) { return(02_0007); } if (!CheckVendor.NotValidResponse(sr)) { _serverResponse = sr; } return(sr.Message); }
private void Button_Click_2(object sender, RoutedEventArgs e) { var email = Email.Text; _sr.InteractiveTask(() => { if (CheckVendor.NotValidEmail(email)) { Growl.Error("无效邮件地址"); return; } _sr.Email = email; SubwindowNavigator.Navigate(SubwindowPage.RecoveryEmail2); }); }
public int Step1(string username, string email, long[] trace) { if (CheckVendor.NotValidUsername(username) || CheckVendor.NotValidEmail(email) || CheckVendor.NotValidTrace(trace)) { return(03_0010); } _username = username; _email = email; _trace = trace; var recoveryEmail = new RecoveryEmail(); recoveryEmail.Username = username; recoveryEmail.Email = email; recoveryEmail.Trace = trace; recoveryEmail.ReportTime = DateTime.Now; var result = ApiCall.AccountRecoveryEmail.Call(null, new MilvanethProtocol { Context = null, Data = recoveryEmail }); if (!(result.Data is ServerResponse sr)) { return(02_0007); } if (!CheckVendor.NotValidResponse(sr)) { _serverResponse = sr; } return(sr.Message); }
private void Button_Click(object sender, RoutedEventArgs e) { var email = _sr.Email; Task.Run(() => { if (this.Dispatcher != null && !this.Dispatcher.CheckAccess()) { this.Dispatcher.Invoke(() => SendCaptcha.IsEnabled = false); for (var i = 60; i > 0; i--) { this.Dispatcher.Invoke(() => SendCaptcha.Content = $"请稍候({i}s)"); Thread.Sleep(1000); } this.Dispatcher.Invoke(() => SendCaptcha.IsEnabled = true); } else { SendCaptcha.IsEnabled = false; for (var i = 60; i > 0; i--) { SendCaptcha.Content = $"请稍候({i}s)"; Thread.Sleep(1000); } SendCaptcha.IsEnabled = true; } }); _sr.InteractiveTask(() => { int ret; if (CheckVendor.NotValidEmail(email)) { Growl.Error("无效邮件地址"); } _sr.Procedure = null; var local = new RecoveryProcedure(); try { if (string.IsNullOrEmpty(_sr.Username)) { ret = 02_0009; goto FAIL; } ret = local.Step1(_sr.Username, email, Helper.GetTrace()); } catch (HttpRequestException ex) { ret = 02_0000 + (int)(ex.Data["StatusCode"]); } catch (Exception) { ret = 02_0000; } FAIL: if (CheckVendor.NotValidResponseCode(ret)) { Growl.Error(MessageVendor.FormatError(ret)); } else { _sr.Procedure = local; } }); }
public int Step1(LobbyServiceResult service, LobbyCharacterResult character, string username, string displayName, string email, byte[] password, long[] trace) { var registerForm = new RegisterForm(); if (CheckVendor.NotValidService(service)) { return(03_0000); } registerForm.Service = service; if (CheckVendor.NotValidCharacter(character)) { return(03_0000); } registerForm.Character = character; if (CheckVendor.NotValidTrace(trace)) { return(03_0008); } registerForm.Trace = trace; // 4-16个字符,可使用英文、数字和下划线,必须以字母开头 if (CheckVendor.NotValidUsername(username)) { return(03_0001); } registerForm.Username = username; // 2-12个字符,可使用中英文、数字和下划线 if (CheckVendor.NotValidDisplayName(displayName)) { return(03_0003); } registerForm.DisplayName = displayName; if (CheckVendor.NotValidEmail(email)) { return(03_0005); } registerForm.Email = email; // 4个字符以上的中文或8个字符以上的数字和字母 if (CheckVendor.NotValidPassword(password)) { return(03_0007); } _username = username; _password = password; registerForm.Verifier = Srp6Vendor.Srp6Init(username, password, out var salt).ToByteArray(); registerForm.Salt = salt; registerForm.GroupParam = Srp6Vendor.BitLength; registerForm.ReportTime = DateTime.Now; for (var i = 0; i < 3; i++) { var result = ApiCall.AccountCreate.Call(null, new MilvanethProtocol { Context = null, Data = registerForm }); if (!(result.Data is ServerChallenge sc)) { return(02_0007); } if (!CheckVendor.NotValidResponse(sc)) { _serverChallenge = sc; } if (sc.Message != 01_0003) // retry with pow { return(sc.Message); } registerForm.SessionId = sc.SessionId; registerForm.ProofOfWork = ProofOfWorkVendor.CalculateProofOfWork(sc.ProofOfWork); } return(01_0002); }