From 3a550ff23e51b5aaa80b621dc61842740d961258 Mon Sep 17 00:00:00 2001 From: Guillaume Risbourg Date: Tue, 11 Feb 2020 14:44:46 +0100 Subject: [PATCH] [ing/api] Handle login OTP with ActionNeeded --- modules/ing/api/login.py | 4 ++++ modules/ing/api_browser.py | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/ing/api/login.py b/modules/ing/api/login.py index 4a27be0af9..11cf976607 100644 --- a/modules/ing/api/login.py +++ b/modules/ing/api/login.py @@ -41,6 +41,10 @@ def init_vk(self, img, password): # 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' diff --git a/modules/ing/api_browser.py b/modules/ing/api_browser.py index cbc8fe97c1..cee8f665d8 100644 --- a/modules/ing/api_browser.py +++ b/modules/ing/api_browser.py @@ -203,9 +203,12 @@ def do_login(self): 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() -- GitLab