Skip to content
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

feat(interceptors): add UnauthorizedInterceptor to handle 401 errors #930

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

Alwein
Copy link
Collaborator

@Alwein Alwein commented Jan 20, 2025

No description provided.

import 'package:pass_emploi_app/repositories/remote_config_repository.dart';
import 'package:redux/redux.dart';

class UnauthorizedInterceptor extends PassEmploiBaseInterceptor {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut etre nommer l'interceptor en LogoutAfterTooMany401Interceptor ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonne idée


@override
void onPassEmploiError(DioException err, ErrorInterceptorHandler handler) {
final maxUnauthorizedErrorsBeforeLogout = _remoteConfigRepository.maxUnauthorizedErrorsBeforeLogout();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en termes de perf ça bouffe quoi d'avoir ce genre d'interceptor qui écoute en permanence les status code d'appel d'api ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pas grand chose. C'est un appel de fonction en plus avec un if. Il n'y a pas de grosse logique donc même avec un iphone 4s pas de soucis

}

void _onUnauthorizedErrorCountExceeded() {
_store.dispatch(RequestLogoutAction(LogoutReason.tooMany401));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

et cette fonction elle force le logout aussi ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui le logout est piloté dans Redux

Copy link
Contributor

@Mzem Mzem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG BG

@Alwein Alwein merged commit def209b into main Jan 27, 2025
7 checks passed
@Alwein Alwein deleted the feat/401-handling branch January 27, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants