From 1f9304492c1139495a4dd49c8dd9db17b3a09516 Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Tue, 21 Jul 2020 19:04:24 +0200 Subject: [PATCH] [ing] better fix for 500 errors encountered after visiting life insurances First, don't go on a non-LoggedPage at the end of iter_accounts, it can only lead to being delogged mindlessly. The real problem is the site fails with a 500 when a Referer doesn not point to /secure (what a bunch of idiots), and the life insurances URL doesn't have /secure, so after visiting them with go(), we set a bad Referer. Use open() instead, so the Referer is not set to a "bad" URL. --- modules/ing/api_browser.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/ing/api_browser.py b/modules/ing/api_browser.py index 9e90636674..2410549cfa 100644 --- a/modules/ing/api_browser.py +++ b/modules/ing/api_browser.py @@ -309,20 +309,18 @@ def get_api_accounts(self): # If the balance is 0, the details page throws an error 500 if account.type == Account.TYPE_LIFE_INSURANCE: if account.balance != 0: - self.life_insurance.go( + # Prefer do an open() NOT to set the life insurance url as next Referer. + # If the Referer doesn't point to /secure, the site might do error 500... + page = self.life_insurance.open( account_uid=account._uid, headers={ 'Authorization': 'Bearer %s' % self.get_invest_token(), } ) - self.page.fill_account(obj=account) + page.fill_account(obj=account) yield account - # The life insurance page is on a different space, - # sometimes we get an error 500 if we don't go back to this page - self.context.go() - @need_login def iter_matching_accounts(self): """Do accounts matching for old and new website""" -- GitLab