protected async override void OnAppearing() { base.OnAppearing(); _broadcasterService.Subscribe(nameof(TwoFactorPage), async(message) => { if (message.Command == "gotYubiKeyOTP") { if (_vm.YubikeyMethod) { _vm.Token = (string)message.Data; await _vm.SubmitAsync(); } } else if (message.Command == "resumeYubiKey") { if (_vm.YubikeyMethod) { _messagingService.Send("listenYubiKeyOTP", true); } } }); await LoadOnAppearedAsync(_scrollView, true, () => { _vm.Init(); if (_vm.TotpMethod) { RequestFocus(_totpEntry); } return(Task.FromResult(0)); }); }
protected async override void OnAppearing() { base.OnAppearing(); _broadcasterService.Subscribe(nameof(TwoFactorPage), (message) => { if (message.Command == "gotYubiKeyOTP") { var token = (string)message.Data; if (_vm.YubikeyMethod && !string.IsNullOrWhiteSpace(token) && token.Length == 44 && !token.Contains(" ")) { Device.BeginInvokeOnMainThread(async() => { _vm.Token = token; await _vm.SubmitAsync(); }); } } else if (message.Command == "resumeYubiKey") { if (_vm.YubikeyMethod) { _messagingService.Send("listenYubiKeyOTP", true); } } else if (message.Command == "gotFido2Token") // Receive the token to send in response t the server about two-factor { // Check if valid var token = (string)message.Data; if (!string.IsNullOrWhiteSpace(token)) { // send to the api service Device.BeginInvokeOnMainThread(async() => { _vm.Token = token; await _vm.SubmitAsync(); }); } } }); await LoadOnAppearedAsync(_scrollView, true, () => { if (!_inited) { _inited = true; _vm.Init(); } if (_vm.TotpMethod) { RequestFocus(_totpEntry); } return(Task.FromResult(0)); }); }