AuthService class

Servicio de autenticación que orquesta AuthRepository y FlutterSecureStorage.

Gestiona el ciclo de vida completo de la sesión:

  • Login (autenticación + persistencia del JWT).
  • Logout (limpieza del almacenamiento seguro).
  • Validación y decodificación local del JWT sin llamada a red.
  • Restauración de sesión al arrancar la app.

Constructors

AuthService({required AuthRepository authRepository, required FlutterSecureStorage storage})

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getToken() Future<String?>
Recupera el JWT almacenado, o null si no existe sesión.
initializeSession() Future<Map<String, dynamic>?>
Inicializa la sesión al arrancar la app:
isTokenValid() Future<bool>
Comprueba si el token en storage existe y no ha caducado. No realiza ninguna llamada a la API.
logout() Future<void>
Cierra la sesión eliminando todos los datos del almacenamiento seguro.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
signIn(String email, String password) Future<AuthResponse>
Inicia sesión y persiste el JWT en el almacenamiento seguro.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited