flutter_token_auth 0.2.1
flutter_token_auth: ^0.2.1 copied to clipboard
A package for handling token-based authentication in Flutter.
Implements a basic system for managing token-based authentication. This is designed specifically to interact neatly with https://github.com/lynndylanhurley/devise_token_auth.
Features #
- Persisting of user in local storage to avoid re-authentication
- Validation of token to ensure user is authenticated
- Login / Logout
- Test mocking
Getting started #
The first time that AuthManager is instantiated on the app launch it must be instantiated with an AuthConfig. The only required url there is your server's url (eg: app.example.com) provided that the other paths follow the defaults.
This is best placed in your main.dart file.
AuthManager(config: AuthConfig(appUrl: "app.example.com"));
Usage #
AuthManager.login('user@example.com', 'password'); // login a user
AuthManager.currentUser; // get the current user
await AuthManager.loadFromStorage(); // on app load, retreive the cached local user
There are additional settings to be passed in in AuthConfig, see the interface in https://github.com/diarmuidr3d/flutter_token_auth/blob/main/lib/src/auth_config.dart for example
Additional information #
TODO