diff --git a/modules/bnporc/enterprise/browser.py b/modules/bnporc/enterprise/browser.py index e7b752d27bd02924caf0ea363d8ee277819bbea1..b644d670224f2bc5344e226797c0f76e9a6768d2 100644 --- a/modules/bnporc/enterprise/browser.py +++ b/modules/bnporc/enterprise/browser.py @@ -65,8 +65,8 @@ class BNPEnterprise(LoginBrowser): renew_pass = URL('/sommaire/PseRedirectPasswordConnect', ActionNeededPage) - def __init__(self, *args, **kwargs): - super(BNPEnterprise, self).__init__(*args, **kwargs) + def __init__(self, config, *args, **kwargs): + super(BNPEnterprise, self).__init__(config['login'].get(), config['password'].get(), *args, **kwargs) def do_login(self): self.login.go() diff --git a/modules/bnporc/module.py b/modules/bnporc/module.py index 26046535ceed245916330141a8fda2ba7c4113bc..803e513825d763b1ac38afa08e2dfd1cc2ea8ea2 100644 --- a/modules/bnporc/module.py +++ b/modules/bnporc/module.py @@ -32,7 +32,7 @@ from weboob.capabilities.profile import CapProfile from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig -from weboob.tools.value import ValueBackendPassword, Value +from weboob.tools.value import ValueBackendPassword, Value, ValueBool from .enterprise.browser import BNPEnterprise from .company.browser import BNPCompany @@ -52,9 +52,7 @@ class BNPorcModule(Module, CapBankWealth, CapBankTransferAddRecipient, CapMessag CONFIG = BackendConfig( ValueBackendPassword('login', label=u'Numéro client', masked=False), ValueBackendPassword('password', label=u'Code secret', regexp='^(\d{6})$'), - #ValueBackendPassword('rotating_password', default='', - # label='Password to set when the allowed uses are exhausted (6 digits)', - # regexp='^(\d{6}|)$'), + ValueBool('rotating_password', label=u'Automatically renew password every 100 connections', default=False), Value('website', label='Type de compte', default='pp', choices={'pp': 'Particuliers/Professionnels', 'hbank': 'HelloBank', @@ -73,10 +71,7 @@ def __init__(self, *args, **kwargs): def create_default_browser(self): b = {'ent': BNPEnterprise, 'ent2': BNPCompany, 'pp': BNPPartPro, 'hbank': HelloBank} self.BROWSER = b[self.config['website'].get()] - if self.BROWSER is BNPPartPro: - return self.create_browser(self.config) - return self.create_browser(self.config['login'].get(), - self.config['password'].get()) + return self.create_browser(self.config) def iter_accounts(self): for account in self.browser.get_accounts_list(): diff --git a/modules/bnporc/pp/browser.py b/modules/bnporc/pp/browser.py index d6643120d2459a77a0a31d87fd5034255d816efe..b67ab731421ddd9d6e40b4c6a8167e1cdb4ee605 100644 --- a/modules/bnporc/pp/browser.py +++ b/modules/bnporc/pp/browser.py @@ -114,10 +114,11 @@ class BNPParibasBrowser(JsonBrowserMixin, LoginBrowser): profile = URL(r'/kyc-wspl/rest/informationsClient', ProfilePage) list_detail_card = URL(r'/udcarte-wspl/rest/listeDetailCartes', ListDetailCardPage) - def __init__(self, *args, **kwargs): - super(BNPParibasBrowser, self).__init__(*args, **kwargs) + def __init__(self, config, *args, **kwargs): + super(BNPParibasBrowser, self).__init__(config['login'].get(), config['password'].get(), *args, **kwargs) self.accounts_list = None self.card_to_transaction_type = {} + self.rotating_password = config['rotating_password'] @retry(ConnectionError, tries=3) def open(self, *args, **kwargs): @@ -406,9 +407,7 @@ class BNPPartPro(BNPParibasBrowser): def __init__(self, config=None, *args, **kwargs): self.config = config - kwargs['username'] = self.config['login'].get() - kwargs['password'] = self.config['password'].get() - super(BNPPartPro, self).__init__(*args, **kwargs) + super(BNPPartPro, self).__init__(self.config, *args, **kwargs) def switch(self, subdomain): self.BASEURL = self.BASEURL_TEMPLATE % subdomain diff --git a/modules/bnporc/pp/pages.py b/modules/bnporc/pp/pages.py index 6d1b7bfbee1649fac9ffea3a51fa5b63e6325fa8..1d460b3551b6ee262ce4c842f2c76e5397dff0ca 100644 --- a/modules/bnporc/pp/pages.py +++ b/modules/bnporc/pp/pages.py @@ -102,6 +102,9 @@ def on_load(self): msg = CleanText('//div[@class="confirmation"]//span[span]')(self.doc) self.logger.warning('Password expired.') + if not self.browser.rotating_password: + raise BrowserPasswordExpired(msg) + if not self.looks_legit(self.browser.password): # we may not be able to restore the password, so reject it self.logger.warning('Unable to restore it, it is not legit.')