arch-atlas

Local Data Source

data/datasources (token cache)

data

Overview

Persists the auth token + cached user in flutter_secure_storage. Read on boot to restore the session, written after login/register, cleared on logout.

User Flow

  1. saveSession(AuthToken, UserModel) — JSON-encodes both, writes under namespaced keys.
  2. readSession() → returns (token, user) or null when absent.
  3. clearSession() — wipes both keys atomically.

Cases & Edge Cases

  • Secure storage unavailable on emulator/web → fall back to SharedPreferences with a clear log warning.
  • Corrupt JSON in storage → treat as 'no session' and clear the keys defensively.

Code References

  • lib/features/auth/data/datasources/local/auth_local_datasource.dart

API Calls

Empty — fill this in later. Open the manifest and add content here.

Notes

Never store the password. Only the issued token + the public user payload. Token rotation invalidates whatever is cached here.