private async void button_Login_Click(object sender, EventArgs e) { textBox_Username.Text = textBox_Username.Text.Trim(); if (string.IsNullOrEmpty(textBox_Username.Text)) { MessageBox.Show("Username cannot be blank"); return; } int totp; if (!int.TryParse(textBox_totp.Text, out totp)) { totp = -1; } Enabled = false; var result = await DiceWebAPI.BeginSessionAsync(Settings.ApiKey, textBox_Username.Text, textBox_Password.Text, totp); if (result.Success) { StartSession(result.Session); } else { Enabled = true; DisplayError(result); } }
private async void button_CreateAccount_Click(object sender, EventArgs e) { if (button_Continue.Enabled) { if (MessageBox.Show(this, "Are you sure? If you create a new account, you will no longer be able to access the old one! To keep access to the old account, choose 'Continue Last Session' and set up a username and password! Continue with creating a new account?", "WARNING", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) { return; } } Enabled = false; var result = await DiceWebAPI.BeginSessionAsync(Settings.ApiKey); if (result.Success) { // Save the account cookie so that we can access this account again SaveLastAccountCookie(result.Session.AccountCookie); StartSession(result.Session); } else { Enabled = true; DisplayError(result); } }
private async void button_Continue_Click(object sender, EventArgs e) { Enabled = false; var result = await DiceWebAPI.BeginSessionAsync(Settings.ApiKey, LastAccountCookie); if (result.Success) { StartSession(result.Session); } else { Enabled = true; DisplayError(result); } }
private async void LoginGo() { BeginSessionResponse result = null; try { result = await DiceWebAPI.BeginSessionAsync(Settings.Default.ApiSettings, _loginModel.Login, _loginModel.Password, int.Parse(_loginModel.GoogleCode == ""?"0": _loginModel.GoogleCode)); } catch (Exception ex) { } if (result != null) { OnLogin?.Invoke(this, new ResultLoginModel { Session = result.Session, ErrorResult = ErrorProcessing(result) }); } }
private async void GetNewAccount() { BeginSessionResponse sessionResult = null; try { sessionResult = await DiceWebAPI.BeginSessionAsync(Settings.Default.ApiSettings); } catch (Exception ex) { } if (sessionResult.Success) { CreateUserResponse newAccResult = null; try { newAccResult = await DiceWebAPI.CreateUserAsync(sessionResult.Session, _newAccountModel.Login, _newAccountModel.PasswordOne); } catch (Exception ex) { } if (newAccResult.Success) { MessageBox.Show("New account created!"); OnLogin?.Invoke(this, _newAccountModel.Login); } else { ErrorProcessingCreateUser(newAccResult); } } else { ErrorProcessingBeginSession(sessionResult); } }