Commit 3a550ff2 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[ing/api] Handle login OTP with ActionNeeded

parent 88f7c421
......@@ -41,6 +41,10 @@ class LoginPage(JsonPage):
# pin positions (website side) start at 1, our positions start at 0
return [password_random_coords[index - 1] for index in pin_position]
def has_strong_authentication(self):
# If this value is at False, this mean there is an OTP needed to login
return not Dict('strongAuthenticationLoginExempted')(self.doc)
def get_password_coord(self, img, password):
assert 'pinPositions' in self.doc, 'Virtualkeyboard position has failed'
assert 'keyPadUrl' in self.doc, 'Virtualkeyboard image url is missing'
......
......@@ -203,9 +203,12 @@ class IngAPIBrowser(LoginBrowser, StatesMixin):
except ClientError as e:
self.handle_login_error(e)
self.auth_token = self.page.response.headers['Ingdf-Auth-Token']
self.session.headers['Ingdf-Auth-Token'] = self.auth_token
self.session.cookies['ingdfAuthToken'] = self.auth_token
if not self.page.has_strong_authentication():
self.auth_token = self.page.response.headers['Ingdf-Auth-Token']
self.session.headers['Ingdf-Auth-Token'] = self.auth_token
self.session.cookies['ingdfAuthToken'] = self.auth_token
else:
raise ActionNeeded("Vous devez réaliser la double authentification sur le portail internet")
# to be on logged page, to avoid relogin
self.accounts.go()
......
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