Development #31822
API : erreur 400 sur tentative de modification d'une adresse email par la même
Début:
28 mars 2019
Echéance:
% réalisé:
0%
Temps estimé:
Patch proposed:
Oui
Planning:
Description
Aujourd'hui,
E AppError: Bad response: 400 BAD REQUEST (not 200) E '{"errors":{"email":["email already used"]},"result":0}'
Fichiers
Révisions associées
api: do not check for email unicity if no change is made (fixes #31822)
Historique
Mis à jour par Frédéric Péters il y a environ 5 ans
- Fichier 0001-tests-check-update-user-with-same-email-31822.patch 0001-tests-check-update-user-with-same-email-31822.patch ajouté
- Statut changé de Nouveau à Solution proposée
- Patch proposed changé de Non à Oui
Mis à jour par Frédéric Péters il y a environ 5 ans
- Statut changé de Solution proposée à En cours
- Patch proposed changé de Oui à Non
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
La correction de mon coté:
diff --git a/src/authentic2/api_views.py b/src/authentic2/api_views.py index 6470cd77..2e52488f 100644 --- a/src/authentic2/api_views.py +++ b/src/authentic2/api_views.py @@ -468,9 +468,12 @@ class BaseUserSerializer(serializers.ModelSerializer): already_used = False if data.get('email'): - if app_settings.A2_EMAIL_IS_UNIQUE and qs.filter(email=data['email']).exists(): + email_qs = qs + if self.instance is not None: + email_qs = email_qs.exclude(pk=self.instance.pk) + if app_settings.A2_EMAIL_IS_UNIQUE and email_qs.filter(email=data['email']).exists(): already_used = True - if ou and ou.email_is_unique and qs.filter(ou=ou, email=data['email']).exists(): + if ou and ou.email_is_unique and email_qs.filter(ou=ou, email=data['email']).exists(): already_used = True if already_used:
Mis à jour par Emmanuel Cazenave il y a environ 5 ans
- Fichier 0002-api-allow-email-data-in-user-update-31822.patch 0002-api-allow-email-data-in-user-update-31822.patch ajouté
- Statut changé de En cours à Solution proposée
- Patch proposed changé de Non à Oui
Je ne vais pas défendre ce patch mordicus, alea jacta est.
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Fichier 0002-api-do-not-check-for-email-unicity-if-no-change-is-m.patch 0002-api-do-not-check-for-email-unicity-if-no-change-is-m.patch ajouté
- Fichier 0001-tests-check-update-user-with-same-email-31822.patch 0001-tests-check-update-user-with-same-email-31822.patch ajouté
- Tracker changé de Bug à Development
Je préfère celui-ci, je comprends mieux.
Mis à jour par Emmanuel Cazenave il y a environ 5 ans
Aucun problème pour mettre mon patch à la poubelle, mais le tien est bizarre, on peut rentrer dans ce if
même si pas de mail envoyé dans les data, on devrait ne pas y mettre les pieds si pas de mail reçu.
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Fichier 0002-api-do-not-check-for-email-unicity-if-no-change-is-m.patch 0002-api-do-not-check-for-email-unicity-if-no-change-is-m.patch ajouté
- Fichier 0001-tests-check-update-user-with-same-email-31822.patch 0001-tests-check-update-user-with-same-email-31822.patch ajouté
Nouvelle tentative.
Mis à jour par Emmanuel Cazenave il y a environ 5 ans
- Statut changé de Solution proposée à Solution validée
Go si les tests passent of course.
Mis à jour par Nicolas Roche il y a environ 5 ans
- Assigné à
Benjamin Dauvergnesupprimé
Ma petite contribution...
je ne connais pas a2, mais je valide dans le sens où :
- j'ai réussit à rejouer le test chez moi
- le patch permet de faire passer le test
- j'ai exploré vite fait la correction avec pdb
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Statut changé de Solution validée à Résolu (à déployer)
commit b8998657cd01f31a17b2f30229a203f40afef19b Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Mar 28 16:56:01 2019 +0100 api: do not check for email unicity if no change is made (fixes #31822) commit ebee7aa1459ed86c7452568403b848a8257c7514 Author: Frédéric Péters <fpeters@entrouvert.com> Date: Thu Mar 28 14:43:48 2019 +0100 tests: check update user with same email (#31822)
Mis à jour par Benjamin Dauvergne il y a environ 5 ans
- Statut changé de Résolu (à déployer) à Solution déployée
- Assigné à
Benjamin Dauvergnesupprimé
Taggé en 2.1.58.
tests: check update user with same email (#31822)