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

fix breaking change (caused by flask_login) on Geonature password change route #191

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

jacquesfize
Copy link
Contributor

Flask login redirects automatically to login page when user not authorized. This change cause the password change mecanism of Geonature to break.

Fix with a custom error handler on the LoginManager instantiated by flask_login

@jacquesfize jacquesfize changed the title fix breaking change (caused by flask_login) on password change route fix breaking change (caused by flask_login) on Geonature password change route Nov 22, 2023
Copy link
Contributor

@bouttier bouttier left a comment

Choose a reason for hiding this comment

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

Le comportement me semble pouvoir être extrapoler à l’ensemble des routes de l’API : s’il s’agit d’un appel d’API effectué par un front, on renvoi le code d’erreur 401 et le front adopte le comportement approprié ; s’il s’agit d’un accès direct via le navigateur, on redirige vers la page de login.
C’est ce qui est fait côté GeoNature en se basant sur le mimetype pour savoir s’il s’agit d’un appel d’API : https://github.com/PnX-SI/GeoNature/blob/master/backend/geonature/core/errors.py#L15
Je pense que le même comportement peut être repris sur UsersHub. À vérifier que les appels d’API sont bien effectué avec accept application/json …

@jacquesfize
Copy link
Contributor Author

J'ai fait la modification pour qu'il ne s'appuie plus sur une liste de routes mais sur le Content-Type.

jacquesfize added a commit to PnX-SI/UsersHub-authentification-module that referenced this pull request Nov 23, 2023
@jacquesfize jacquesfize merged commit 131c620 into develop Nov 28, 2023
jacquesfize added a commit to PnX-SI/UsersHub-authentification-module that referenced this pull request Nov 28, 2023
* (fix required for PnX-SI/UsersHub#191) + drop deprecated import of escape + add header for test connexion to UsersHub
@camillemonchicourt camillemonchicourt deleted the fix/error_changepasswd branch January 26, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants