class _ProxmoxTfaFormState extends State<ProxmoxTfaForm> {
final TextEditingController _codeController = TextEditingController();
bool _isLoading = false;
+ List<String> _tfa_kinds = [];
+ String _selected_tfa_kind = "";
+
+ @override
+ void initState() {
+ super.initState();
+ _tfa_kinds = widget.apiClient!.credentials.tfa!.kinds().toList();
+ _selected_tfa_kind = _tfa_kinds[0];
+ }
+
@override
Widget build(BuildContext context) {
return Theme(
Padding(
padding: const EdgeInsets.fromLTRB(0, 50.0, 0, 8.0),
child: Container(
- width: 150,
- child: TextField(
- controller: _codeController,
- textAlign: TextAlign.center,
- decoration: InputDecoration(labelText: 'Code'),
- autofocus: true,
- onSubmitted: (value) => _submitTfaCode()),
+ width: 175,
+ child: Column(
+ children: <Widget>[
+ DropdownButtonFormField(
+ decoration: InputDecoration(
+ labelText: 'Method',
+ icon: Icon(Icons.input)),
+ items: _tfa_kinds
+ .map((e) => DropdownMenuItem(
+ child: ListTile(title: Text(e)),
+ value: e,
+ ))
+ .toList(),
+ onChanged: (String? value) {
+ setState(() {
+ _selected_tfa_kind = value!;
+ });
+ },
+ selectedItemBuilder: (context) =>
+ _tfa_kinds.map((e) => Text(e)).toList(),
+ value: _selected_tfa_kind,
+ ),
+ TextField(
+ controller: _codeController,
+ textAlign: TextAlign.center,
+ decoration: InputDecoration(
+ labelText: 'Code', icon: Icon(Icons.pin)),
+ autofocus: true,
+ onSubmitted: (value) => _submitTfaCode()),
+ ],
+ ),
),
),
Expanded(
_isLoading = true;
});
try {
- final client =
- await widget.apiClient!.finishTfaChallenge(_codeController.text);
+ final client = await widget.apiClient!
+ .finishTfaChallenge(_selected_tfa_kind, _codeController.text);
Navigator.of(context).pop(client);
} on ProxmoxApiException catch (e) {
showDialog(