loadSession method

  1. @override
Future<DescopeSession?> loadSession()
override

Called by the session manager when it's initialized to load any existing DescopeSession.

Implementation

@override
Future<DescopeSession?> loadSession() async {
  final data = await _store.loadItem(_projectId);
  if (data != null) {
    try {
      final decoded = jsonDecode(data) as Map<String, dynamic>;
      final value = _Value.fromJson(decoded);
      return DescopeSession.fromJwt(value.sessionJwt, value.refreshJwt, value.user);
    } on Exception {
      return null;
    }
  }
  return null;
}