The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit 14c6f915 authored by Damien Mat's avatar Damien Mat Committed by Vincent A

[hsbc] handle user locked

Detected after username submission.
Since we weren't handling this case, login was proceeding
to 2FA notification instead of stopping here.
parent d3c2bdf3
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
from weboob.tools.capabilities.bank.transactions import sorted_transactions, keep_only_card_transactions from weboob.tools.capabilities.bank.transactions import sorted_transactions, keep_only_card_transactions
from weboob.tools.compat import parse_qsl, urlparse from weboob.tools.compat import parse_qsl, urlparse
from weboob.tools.value import Value from weboob.tools.value import Value
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, BrowserQuestion from weboob.exceptions import ActionNeeded, BrowserIncorrectPassword, BrowserUnavailable, BrowserQuestion
from weboob.browser import URL, need_login, TwoFactorBrowser from weboob.browser import URL, need_login, TwoFactorBrowser
from weboob.browser.exceptions import HTTPNotFound from weboob.browser.exceptions import HTTPNotFound
from weboob.capabilities.base import find_object from weboob.capabilities.base import find_object
...@@ -190,6 +190,12 @@ def init_login(self): ...@@ -190,6 +190,12 @@ def init_login(self):
if no_secure_key_link: if no_secure_key_link:
self.location(no_secure_key_link) self.location(no_secure_key_link)
else: else:
error = self.page.get_error()
if error and 'Please click Reset Credentials' in error:
raise ActionNeeded(error)
elif error:
raise AssertionError('Unhandled error at login: %s' % error)
self.check_interactive() self.check_interactive()
raise BrowserQuestion( raise BrowserQuestion(
Value( Value(
......
...@@ -554,6 +554,9 @@ def login(self, login): ...@@ -554,6 +554,9 @@ def login(self, login):
form['userid'] = form['__hbfruserid'] = login form['userid'] = form['__hbfruserid'] = login
form.submit() form.submit()
def get_error(self):
return CleanText('//div[contains(@class, "PanelMsgGroup")]')(self.doc)
def get_no_secure_key_link(self): def get_no_secure_key_link(self):
try: try:
a = self.doc.xpath('//a[contains(text(), "Without HSBC Secure Key")]')[0] a = self.doc.xpath('//a[contains(text(), "Without HSBC Secure Key")]')[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment