public static bool Authenticate(Form owner, bool asAdmin, bool change) { try { using (PasswordForm form = new PasswordForm()) { form.IsInAdminContext = asAdmin; if (form.ShowDialog(owner) == DialogResult.OK) { form.AuthenticateInternal(); if (change) { ChangePassword(form, asAdmin); } return(true); } } return(false); } catch (Exception ex) { ex.ShowDialog(owner); return(false); } }
private void Settings_Click(object sender, EventArgs e) { if (PasswordForm.Authenticate(this, true, false)) { using (SettingsForm form = new SettingsForm()) form.ShowDialog(this); } }
protected override void OnShown(EventArgs e) { if (PasswordForm.ChangePassword(this, false)) { new MethodInvoker(() => { var url = SettingsTable.Get <string>(Strings.All_CentralServerUrl, Strings.All_CentralServerUrlPathDefault); var authUser = SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject); DBConfigValue.Save(Strings.Transferring_AuthObject, authUser); var settingsObj = SettingsTable.Get <SettingsObj>(Strings.Transferring_SettingsObject, SettingsObj.Default); //Send to win service DBConfigValue.Save(Strings.Transferring_SettingsObject, settingsObj); }).FireAndForget(); } base.OnShown(e); }
private void Unlock() { if (PasswordForm.Authenticate(this, false, false)) { new MethodInvoker(() => { var url = SettingsTable.Get <string>(Strings.All_CentralServerUrl, Strings.All_CentralServerUrlPathDefault); var authUser = SettingsTable.Get <UserAuth>(Strings.Transferring_AuthObject); var countryId = SettingsTable.Get <int>(Strings.VScan_DefaultCountryCode, 826); //authUser.PassHash = ReceivingWebService.ValidateUser(authUser, url); #warning TODO SettingsTable.Set(Strings.Transferring_AuthObject, authUser); DBConfigValue.Save(Strings.Transferring_AuthObject, authUser); Stop(); }).FireAndForget(); } }
public static bool ChangePassword(Form owner, bool asAdmin) { try { using (PasswordForm form = new PasswordForm()) { form.IsInAdminContext = asAdmin; form.ChangePasswordAction = true; form.ShowCountries = true; if (form.ShowDialog(owner) == DialogResult.OK) { form.ChangePasswordInternal(owner); return(true); } } return(false); } catch (Exception ex) { ex.ShowDialog(owner); return(false); } }