Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

How to implement redirection inside Interceptor? #2395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bambinoua opened this issue Apr 18, 2025 · 0 comments
Closed

How to implement redirection inside Interceptor? #2395

bambinoua opened this issue Apr 18, 2025 · 0 comments
Labels
s: feature This issue indicates a feature request

Comments

@bambinoua
Copy link

bambinoua commented Apr 18, 2025

I have a ValidationInterceptor which should force logout when some event is occurred.

How can I do this?

class ValidationInterceptor extends Interceptor {
  @override
  onError(DioException err, ErrorInterceptorHandler handler) {
    if(err.type == DioResponseType.badRequest && err.response!.statusCode == 401) {
      final logoutUri = Uri(path: '/logout');
      // ...
      // need to redirect to logout
      // ...
      handler.reject(err); // do I need this?
    } else {
      handler.next(err);
    }
  }
}
@bambinoua bambinoua added the s: feature This issue indicates a feature request label Apr 18, 2025
@cfug cfug locked and limited conversation to collaborators May 14, 2025
@AlexV525 AlexV525 converted this issue into discussion #2401 May 14, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
s: feature This issue indicates a feature request
Projects
None yet
Development

No branches or pull requests

1 participant