feat(app): phone onboarding (server, then password) kept across launches; a known server opens straight into the app; a refused session asks for the password

This commit is contained in:
2026-10-23 23:52:34 +01:00
parent 57504b73d4
commit 636115bb22
12 changed files with 650 additions and 33 deletions
+15
View File
@@ -61,8 +61,23 @@ class ServerSession {
}
static Future<void> signOut() => _save(null);
/// Whether [endpoint]'s server accepts the kept session.
static Future<SessionState> check(Uri endpoint) async {
final login = loginUriFor(endpoint);
if (login == null) return SessionState.unreachable;
final status = await impl.probeLogin(login, headers);
if (status == null) return SessionState.unreachable;
// The web login sends a signed-in visitor on; it shows its form otherwise.
if (status >= 300 && status < 400) return SessionState.signedIn;
if (status == 200) return SessionState.signedOut;
return SessionState.unreachable;
}
}
/// What a server says about this device's session.
enum SessionState { signedIn, signedOut, unreachable }
/// The web login page for a websocket endpoint: same host and port, http(s).
Uri? loginUriFor(Uri endpoint) {
final scheme = switch (endpoint.scheme) {