added support for 2fa login with browser flow

This commit is contained in:
2026-08-10 20:00:38 +02:00
parent 889d8f67c5
commit ccb22a497d
13 changed files with 805 additions and 35 deletions
+19 -2
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../../routing/app_routes.dart';
import '../login_controller.dart';
import 'login_error_banner.dart';
@@ -51,11 +52,27 @@ class _LoginCardState extends State<LoginCard> {
Future<void> _submit() async {
if (widget.controller.loading) return;
if (!(_formKey.currentState?.validate() ?? false)) return;
final ok = await widget.controller.submit(
final result = await widget.controller.submit(
_usernameController.text,
_passwordController.text,
);
if (ok && mounted) widget.onSuccess();
if (!mounted) return;
switch (result) {
case LoginResult.success:
widget.onSuccess();
case LoginResult.nextcloudLoginRequired:
// 2FA (oder abweichendes NC-Passwort): Anmeldung im Browser über den
// Login Flow v2 abschließen; ohne Erfolg wird der Login zurückgerollt.
final ok = await AppRoutes.openNextcloudLoginFlow(context);
if (!mounted) return;
if (ok) {
widget.onSuccess();
} else {
await widget.controller.abortNextcloudLogin();
}
case LoginResult.failure:
break;
}
}
InputDecoration _decoration(ThemeData theme, String label, IconData icon) =>