コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: rrossenbg/vprint
 private void Settings_Click(object sender, EventArgs e)
 {
     if (PasswordForm.Authenticate(this, true, false))
     {
         using (SettingsForm form = new SettingsForm())
             form.ShowDialog(this);
     }
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: rrossenbg/vprint
        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);
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        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);
            }
        }