コード例 #1
0
        private void BtnGoogleAuth_Click(object sender, EventArgs e)
        {
            if (_gAuthEnabled)
            {
                // Before removing authenticator, check that they can input a correct PIN
                string userPin = TxtPin.Text.Trim().Replace(" ", "");
                string softPin = GAuth.GeneratePin(Program.storage.gAuthKey);
                if (!softPin.Equals(userPin))
                {
                    // PIN is incorrect
                    MessageBox.Show(this, "Entered PIN is incorrect, please try again.", "Warning!");
                    return;
                }

                // PIN entered was correct, so remove GAuth data from storage object
                Program.storage.gAuthKey = null;

                // Inform user that Google Authenticator has been disabled
                MessageBox.Show(this, "Google Authenticator has been disabled for the current database.\n" +
                                "Please remember to save these changes to file.", "Success!");

                // Show success DialogResult
                DialogResult = DialogResult.OK;
            }
            else
            {
                using (GAuthForm gAuth = new GAuthForm(Path.GetFileName(Program.storage.SessionPath)))
                {
                    if (gAuth.ShowDialog() == DialogResult.OK)
                    {
                        // Enable Google Authenticator in storage object
                        Program.storage.gAuthKey = gAuth.Secret;

                        // Inform the user that Google Authenticator has been enabled
                        MessageBox.Show(this, "Google Authenticator has been enabled for the current database.\n" +
                                        "Please remember to save these changes to file.", "Success!");

                        // Show success DialogResult
                        DialogResult = DialogResult.OK;
                    }
                }
            }
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: sietse23/GDrive
        public FormMain()
        {
            InitializeComponent();

            m_DriveService = new DriveService(GAuth.CreateAuthenticator());
        }
コード例 #3
0
        /********************************************** Constructor, Load & Closing ************************************************/

        public DriveSync()
        {
            m_Drive = new DriveService(GAuth.CreateAuthenticator());
        }