From 415f2317ec171ce94dc4f4991ba8f160b68d0018 Mon Sep 17 00:00:00 2001 From: Lucas Ficheux Date: Wed, 13 May 2020 19:06:27 +0200 Subject: [PATCH] [caissedepargne] Raise BrowserPasswordExpired The module did not handle the case when a user needs to renew their password so it crashed. This commit fixes that by checking for a key in the json responses of icgauth. --- modules/caissedepargne/pages.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 26d55086f2..970790bcf2 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -55,6 +55,7 @@ from weboob.tools.compat import unicode from weboob.exceptions import ( NoAccountsException, BrowserUnavailable, ActionNeeded, BrowserIncorrectPassword, + BrowserPasswordExpired, ) from weboob.browser.filters.json import Dict from weboob.browser.exceptions import ClientError @@ -121,7 +122,11 @@ def get_validation_id(self): @property def validation_units(self): - return Dict('step/validationUnits')(self.doc)[0] + units = Coalesce( + Dict('step/validationUnits', default=None), + Dict('validationUnits', default=None), + )(self.doc) + return units[0] @property def validation_unit_id(self): @@ -142,6 +147,8 @@ def login_errors(self, error): # So it does not require any action from the user and is automatic. if error in ('FAILED_AUTHENTICATION', 'AUTHENTICATION_LOCKED', 'AUTHENTICATION_FAILED'): raise BrowserIncorrectPassword() + if error in ('ENROLLMENT', ): + raise BrowserPasswordExpired() def transfer_errors(self, error): if error == 'FAILED_AUTHENTICATION': @@ -163,6 +170,8 @@ def check_errors(self, feature): # error will be handle in `if` case. # If there is no error, it will retrive 'AUTHENTICATION' as result value. result = self.doc['step']['phase']['state'] + elif 'phase' in self.doc and self.get_authentication_method_type() == 'PASSWORD_ENROLL': + result = self.doc['phase']['state'] else: result = self.doc['phase']['previousResult'] -- GitLab