public OtpInputDialog()
        {
            InitializeComponent();

            this.DataContext = new OtpInputDialogViewModel();

            OtpTextBox.Focus();

            if (App.Settings.OtpServerEnabled)
            {
                _otpListener = new OtpListener();
                _otpListener.OnOtpReceived += otp =>
                {
                    Result = otp;
                    Dispatcher.Invoke(() =>
                    {
                        Close();
                        _otpListener?.Stop();
                    });
                };

                try
                {
                    // Start Listen
                    Task.Run(() => _otpListener.Start());
                    Log.Debug("OTP server started...");
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Could not start OTP HTTP listener.");
                }
            }
        }
        public OtpInputDialog()
        {
            InitializeComponent();

            OtpTextBox.Focus();

            _otpListener = new OtpListener();
            _otpListener.OnOtpReceived += otp =>
            {
                Result = otp;
                Dispatcher.Invoke(() =>
                {
                    Close();
                    _otpListener.Stop();
                });
            };

            try
            {
                // Start Listen
                Task.Run(() => _otpListener.Start());
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Could not start OTP HTTP listener.");
            }
        }
Exemple #3
0
        public new bool?ShowDialog()
        {
            OtpTextBox.Focus();

            if (App.Settings.OtpServerEnabled)
            {
                _otpListener = new OtpListener("legacy-" + AppUtil.GetAssemblyVersion());
                _otpListener.OnOtpReceived += TryAcceptOtp;

                try
                {
                    // Start Listen
                    Task.Run(() => _otpListener.Start());
                    Log.Debug("OTP server started...");
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Could not start OTP HTTP listener.");
                }
            }

            return(base.ShowDialog());
        }