flutter-template
flutter-template copied to clipboard
fix(#80): AuthInterceptor implementation is incomplete
Resolves #80
Introduced:
- A new
Authenticatorclass that is responsible for:- Making the tokens accessible by other classes such as interceptors. This class is the source of truth
- Trying to reauthenticate the user. The new interceptor,
ApiAuthInterceptor, is usingAuthenticatorto reauth if needed.
- A new
ApiAuthInterceptorclass. It is a rewritten version of the old interceptor — more readable and straightforward. This interceptor is aQueuedInterceptornow — meaning that, if we await for something, other request calls will wait until this call is resolved.
Both of the classes are covered with tests. If you think that not all the scenarios are covered — please let me know, I'll add those.
Also, we now use FlutterSecureStorage for storing the tokens. It is safer. BUT! This storage survives app uninstallation IIRC. So we should consider creating something that will detect fresh installation and clear the storage. Something like storing a value with the freshInstallation key in the shared prefs of the app.
Changes with build context and response errors are related to the freezed generator failing to build with material library imports..