Add account: check length of issuer and name

This commit is contained in:
Dennis Fokin 2022-04-01 15:05:26 +02:00
parent f6aeb0b9f0
commit 4c39e793cd
No known key found for this signature in database
GPG Key ID: 870B88256690D8BC

View File

@ -104,8 +104,11 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
final secret = _secretController.text.replaceAll(' ', ''); final secret = _secretController.text.replaceAll(' ', '');
final secretLengthValid = secret.length * 5 % 8 < 5; final secretLengthValid = secret.length * 5 % 8 < 5;
final isValid = final isValid = _accountController.text.isNotEmpty &&
_accountController.text.isNotEmpty && secret.isNotEmpty && period > 0; secret.isNotEmpty &&
issuerRemaining >= -1 &&
nameRemaining >= 0 &&
period > 0;
final qrScanner = ref.watch(qrScannerProvider); final qrScanner = ref.watch(qrScannerProvider);
@ -154,7 +157,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
), ),
TextField( TextField(
controller: _accountController, controller: _accountController,
maxLength: nameRemaining, maxLength: max(nameRemaining, 1),
decoration: const InputDecoration( decoration: const InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Account name', labelText: 'Account name',