mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-24 10:42:47 +03:00
Show message on OATH add account failure.
This commit is contained in:
parent
479b9bc9c1
commit
2efbad0501
@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../../app/message.dart';
|
||||
import '../../app/state.dart';
|
||||
@ -14,6 +15,8 @@ import '../models.dart';
|
||||
import '../state.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
final _log = Logger('oath.view.add_account_page');
|
||||
|
||||
final _secretFormatterPattern =
|
||||
RegExp('[abcdefghijklmnopqrstuvwxyz234567 ]', caseSensitive: false);
|
||||
|
||||
@ -340,7 +343,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: isValid
|
||||
? () {
|
||||
? () async {
|
||||
if (secretLengthValid) {
|
||||
final issuer = _issuerController.text;
|
||||
|
||||
@ -354,12 +357,17 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
||||
period: period,
|
||||
);
|
||||
|
||||
ref
|
||||
.read(
|
||||
credentialListProvider(widget.devicePath).notifier)
|
||||
.addAccount(cred.toUri(), requireTouch: _touch);
|
||||
Navigator.of(context).pop();
|
||||
showMessage(context, 'Account added');
|
||||
try {
|
||||
await ref
|
||||
.read(credentialListProvider(widget.devicePath)
|
||||
.notifier)
|
||||
.addAccount(cred.toUri(), requireTouch: _touch);
|
||||
Navigator.of(context).pop();
|
||||
showMessage(context, 'Account added');
|
||||
} catch (e) {
|
||||
_log.severe('Failed to add account', e);
|
||||
showMessage(context, 'Failed adding account');
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
_validateSecretLength = true;
|
||||
|
Loading…
Reference in New Issue
Block a user