From c99f5010cf20b9de6a13a4b3fe98095f84811ded Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Tue, 5 Jan 2021 19:25:50 +0100 Subject: [PATCH] [lcl] Handle BrowserPasswordExpired --- modules/lcl/browser.py | 9 ++++++++- modules/lcl/pages.py | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/lcl/browser.py b/modules/lcl/browser.py index f2fce55c7c..cb6b98739c 100644 --- a/modules/lcl/browser.py +++ b/modules/lcl/browser.py @@ -31,6 +31,7 @@ from weboob.exceptions import ( BrowserIncorrectPassword, BrowserUnavailable, BrowserQuestion, AppValidation, AppValidationCancelled, AppValidationExpired, + BrowserPasswordExpired, ) from weboob.browser import URL, need_login, TwoFactorBrowser from weboob.browser.exceptions import ServerError, ClientError @@ -52,6 +53,7 @@ Form2Page, DocumentsPage, ClientPage, SendTokenPage, CaliePage, ProfilePage, DepositPage, AVHistoryPage, AVInvestmentsPage, CardsPage, AVListPage, CalieContractsPage, RedirectPage, MarketOrdersPage, AVNotAuthorized, AVReroute, TwoFAPage, AuthentStatusPage, FinalizeTwoFAPage, + PasswordExpiredPage, ) @@ -69,7 +71,9 @@ class LCLBrowser(TwoFactorBrowser): r'/outil/UAUT\?from=.*', r'/outil/UWER/Accueil/majicER', r'/outil/UWER/Enregistrement/forwardAcc', - LoginPage) + LoginPage + ) + password_expired_page = URL(r'/outil/UWMC/NoConnect/incitationChangementMdp', PasswordExpiredPage) redirect_page = URL(r'/outil/UAUT/Accueil/preRoutageLogin', RedirectPage) contracts_page = URL( r'/outil/UAUT/Contrat/choixContrat.*', @@ -261,6 +265,9 @@ def init_login(self): if self.login.is_here(): self.page.check_error() + if self.password_expired_page.is_here(): + raise BrowserPasswordExpired(self.page.get_message()) + if (not self.contracts and not self.parsed_contracts and (self.contracts_choice.is_here() or self.contracts_page.is_here())): # On the preRoutageLogin page we gather the list of available contracts for this account diff --git a/modules/lcl/pages.py b/modules/lcl/pages.py index ef0f4dd743..05bb66a83e 100644 --- a/modules/lcl/pages.py +++ b/modules/lcl/pages.py @@ -233,6 +233,11 @@ def select_contract(self, id_contract=None): form.submit() +class PasswordExpiredPage(LoggedPage, HTMLPage): + def get_message(self): + return CleanText('//form[@id="changementCodeForm"]//span[contains(., "nouveau code d’accès")]')(self.doc) + + class ContractsChoicePage(ContractsPage): def on_load(self): self.check_error() -- GitLab