AuthFailureInterceptor class
Dio interceptor that detects runtime authentication failures and notifies the rest of the app to force a logout.
When an UnauthorizedException is detected on a Dio error, this interceptor calls AuthFailureNotifier.notify with a 2-second debounce to prevent multiple notifications from concurrent in-flight requests. The error is then forwarded to the next handler unchanged.
This interceptor must be placed after AppExceptionMappingInterceptor in the
chain so that the error field of the DioException is already a typed
UnauthorizedException when this interceptor inspects it.
See also:
- AuthFailureNotifier for the broadcast stream that listeners subscribe to.
- AppExceptionMappingInterceptor for the upstream error mapping step.
- Inheritance
-
- Object
- Interceptor
- AuthFailureInterceptor
Constructors
- AuthFailureInterceptor({required AuthFailureNotifier notifier})
-
Creates an interceptor that notifies
notifieron authentication failure.
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
-
dispose(
) → void - Cancels the debounce timer and releases resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
DioException err, ErrorInterceptorHandler handler) → void -
Intercepts Dio errors and triggers an auth failure notification when the
error is an UnauthorizedException.
override
-
onRequest(
RequestOptions options, RequestInterceptorHandler handler) → void -
Called when the request is about to be sent.
inherited
-
onResponse(
Response response, ResponseInterceptorHandler handler) → void -
Called when the response is about to be resolved.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited