Пример #1
0
        void enrollwindow_Loaded(object sender, RoutedEventArgs e)
        {
            newAuth = new Authenticator(AuthenticatorSettings.Instance.AuthenticatorAssembly);

            textBox_enrollserial.Text = textBox_enrollcode.Text = textBox_enrollrestore.Text = "Loading ...";
            newAuth.Enroll();
            textBox_enrollserial.Text = newAuth.Serial;
            textBox_enrollcode.Text = newAuth.CurrentCode;
            textBox_enrollrestore.Text = newAuth.RestoreCode;
        }
Пример #2
0
        void button_restorerestore_Click(object sender, RoutedEventArgs e)
        {
            string serial = textBox_restoreserial.Text.Replace("-", "");
            string code = textBox_restorecode.Text;
            if (serial.Length == 14 && code.Length == 10)
            {
                try
                {

                    newAuth = new Authenticator(AuthenticatorSettings.Instance.AuthenticatorAssembly);
                    newAuth.Restore(serial, code);
                    RadsAtom.Auth = newAuth;
                    AuthenticatorSettings.Instance.Serial = newAuth.Serial;
                    AuthenticatorSettings.Instance.SecretKey = Authenticator.ByteArrayToString(newAuth.SecretKey);
                    AuthenticatorSettings.Instance.Save();
                    restoreWindow.Close();
                }
                catch
                {
                    MessageBox.Show("Failed to restore authenticator", "Restore Failed!", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            else
                MessageBox.Show("Incorrect restore information given", "Restore Failed!", MessageBoxButton.OK, MessageBoxImage.Warning);
        }