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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user