added support for multiple accounts, guardian login bugfixes, ui changes

This commit is contained in:
2026-09-23 20:50:12 +02:00
parent 630497abdd
commit 84098af7e2
37 changed files with 1759 additions and 376 deletions
+7 -2
View File
@@ -61,6 +61,7 @@ class LoginController extends ChangeNotifier {
return LoginResult.success;
}
var signedIn = false;
try {
await _discardPreviousAccount();
// AuthLogin = Credential-Probe + Token-Create in einem Call.
@@ -73,6 +74,7 @@ class LoginController extends ChangeNotifier {
await SessionManager().signIn(
CredentialSession(username: user, password: password),
);
signedIn = true;
// Mint the Nextcloud app password now — it doubles as the Nextcloud
// credential probe: a rejection means 2FA is active (or the NC password
// diverges) and the login must finish interactively in the browser.
@@ -82,7 +84,9 @@ class LoginController extends ChangeNotifier {
return ncReady ? LoginResult.success : LoginResult.nextcloudLoginRequired;
} catch (e) {
log(e.toString());
await SessionManager().signOut();
// Only the account signed in by this attempt; while adding an account
// the active one is parked and restored on cancel.
if (signedIn) await SessionManager().signOut();
await const MarianumConnectTokenStorage().clear();
final isWrongCredentials = e is AuthException && e.statusCode == 401;
_errorMessage = isWrongCredentials
@@ -98,7 +102,8 @@ class LoginController extends ChangeNotifier {
/// Vorherigen Token verwerfen, bevor ein neuer angefordert wird, und den
/// Widget-Snapshot löschen — sonst blitzt nach einem Account-Wechsel kurz
/// der Stundenplan des vorigen Users auf dem Home-Bildschirm. Die Session
/// selbst überschreibt signIn vollständig.
/// selbst überschreibt signIn vollständig; beim Hinzufügen eines Kontos
/// liegt der Token des aktiven Kontos schon in dessen Tresor.
Future<void> _discardPreviousAccount() async {
await const MarianumConnectTokenStorage().clear();
await WidgetSync.clear();