Overview
TheAuthRepository interface handles all authentication-related operations including user login, logout, session validation, and token management. It provides methods for both local and server-side session management.
Methods
login()
Authenticate a user with username and password. Stores the JWT token on successful login. ParametersThe user’s username or email address
The user’s password
Result containing UserSession with JWT token and user details, or error on failure
logout()
Log out the current user by calling the server logout endpoint and clearing stored tokens. ReturnsResult indicating success or failure of logout operation
clearLocalSession()
Clear local tokens without calling the server. Used for immediate local logout when server communication is not required or has failed. Returns Void - no return valueisAuthenticated()
Check if a user is currently authenticated by verifying the presence of a valid stored token. Returnstrue if user has a valid token stored, false otherwisegetCurrentSession()
Retrieve the current user session if authenticated. ReturnsUserSession object if authenticated,
null if not authenticatedvalidateSession()
Validates the current session with the backend by making a lightweight API call to verify the token is still valid. Returnstrue if session is valid, false if expired or invalidUsage Example
Related Documentation
Authentication Flow
Complete authentication implementation guide
UsersRepository
User management operations
User Models
User and UserSession data models
LoginViewModel
Login screen state management