flutter-template icon indicating copy to clipboard operation
flutter-template copied to clipboard

fix(#80): AuthInterceptor implementation is incomplete

Open nivisi opened this issue 2 years ago • 0 comments

Resolves #80


Introduced:

  • A new Authenticator class 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 using Authenticator to reauth if needed.
  • A new ApiAuthInterceptor class. It is a rewritten version of the old interceptor — more readable and straightforward. This interceptor is a QueuedInterceptor now — 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..

nivisi avatar Jan 06 '23 09:01 nivisi