private void loginWithPrompt(bool forceNewCreds = false) { try { SetState(new StateLoggingIn(this)); if (forceNewCreds || _password.Length == 0 || _username.Length == 0 || _server.Length == 0 || _server == ConfigurationManager.AppSettings["ExampleServerURL"]) { if (_server.Length == 0) { string url = ConfigurationManager.AppSettings["FogBugzBaseURL"] ?? ""; _server = (url.Length > 0) ? url : ConfigurationManager.AppSettings["ExampleServerURL"]; } LogonResultInfo info = DoLogonScreen(_username, _password, _server); if (info.UserChoice != DialogResult.Cancel) { _username = info.User; _password = info.Password; _server = info.Server; } } _fb = new FogBugz(_server); LogonAsync(_username, _password, delegate(bool succeeded) { if (succeeded) { saveSettings(); updateCases(); } else { _password = ""; SetState(new StateLoggedOff(this)); MessageBox.Show(@"Login failed", @"FogBugz", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); } catch (Exception) { SetState(new StateLoggedOff(this)); throw; } }
private static LogonResultInfo DoLogonScreen(string initialUser, string initialPassword, string initialServer) { var ret = new LogonResultInfo(); var f = new LoginForm {Password = initialPassword, Email = initialUser, Server = initialServer}; if (f.ShowDialog() == DialogResult.Cancel) ret.UserChoice = DialogResult.Cancel; else { ret.UserChoice = DialogResult.OK; ret.User = f.Email; ret.Password = f.Password; ret.Server = f.Server; } return ret; }
private static LogonResultInfo DoLogonScreen(string initialUser, string initialPassword, string initialServer) { var ret = new LogonResultInfo(); var f = new LoginForm { Password = initialPassword, Email = initialUser, Server = initialServer }; if (f.ShowDialog() == DialogResult.Cancel) { ret.UserChoice = DialogResult.Cancel; } else { ret.UserChoice = DialogResult.OK; ret.User = f.Email; ret.Password = f.Password; ret.Server = f.Server; } return(ret); }