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
+37 -1
View File
@@ -67,6 +67,13 @@ class PushRegistration {
/// registration binds to it, so it must be obtained before registering.
Future<void> ensureAppPassword() async {
if (AccountData().hasAppPassword()) return;
if (AccountData().usesLoginFlow) {
// Flow-Konten (2FA): Basic Auth mit dem echten Passwort wird abgelehnt,
// stilles Minting ist unmöglich. Reparatur nur interaktiv über
// Einstellungen → „Nextcloud neu verbinden".
log('Push: login-flow account without app password, cannot mint silently');
return;
}
try {
final appPassword = await GetAppPassword().run();
await AccountData().setAppPassword(appPassword);
@@ -79,6 +86,11 @@ class PushRegistration {
/// (each `getapppassword` call with the real password mints a fresh one).
Future<void> ensureTalkAppPassword() async {
if (AccountData().hasAppPasswordTalk()) return;
// Flow-Konten können still kein zweites App-Passwort münzen — das
// Talk-Passwort kommt nur aus dem zweiten Login-Flow-Durchlauf; bis dahin
// teilt sich die Talk-Registrierung das eine App-Passwort (siehe
// AccountData.getTalkBasicAuthHeader).
if (AccountData().usesLoginFlow) return;
try {
final appPassword = await GetAppPassword().run();
await AccountData().setAppPasswordTalk(appPassword);
@@ -129,8 +141,19 @@ class PushRegistration {
appVersion = null;
}
final types = registrationTypesFor(
usesLoginFlow: AccountData().usesLoginFlow,
hasTalkAppPassword: AccountData().hasAppPasswordTalk(),
);
if (!types.contains(PushRegistrationType.general)) {
await _recordAttempt(
PushRegistrationType.general,
'Ohne zweite Nextcloud-Freigabe nicht verfügbar (nur Talk-Push)',
);
}
var allOk = true;
for (final type in PushRegistrationType.values) {
for (final type in types) {
final ok = await _registerType(
type: type,
fcmToken: fcmToken,
@@ -260,6 +283,19 @@ class PushRegistration {
await _store.clear();
}
/// Pure decision which Nextcloud registrations this session can maintain.
/// Flow-Konten (2FA), die nur den ersten Login-Flow-Durchlauf abgeschlossen
/// haben, besitzen eine einzige NC-Session — Nextcloud bindet pro Session
/// genau eine Subscription, also bleibt nur die (wichtigere)
/// Talk-Registrierung. Mit dem zweiten (Talk-)App-Passwort aus dem
/// optionalen zweiten Durchlauf laufen wieder beide.
static List<PushRegistrationType> registrationTypesFor({
required bool usesLoginFlow,
required bool hasTalkAppPassword,
}) => usesLoginFlow && !hasTalkAppPassword
? const [PushRegistrationType.talk]
: PushRegistrationType.values;
/// Pure decision for whether a persisted registration endpoint no longer
/// matches the currently active one. A missing/empty stored value never
/// forces a re-registration — old installs (pre endpoint-tracking) heal via