fix login on accounts with several subaccounts
This commit is contained in:
parent
252f3ac6c0
commit
3f5b2c6d41
2 changed files with 31 additions and 7 deletions
|
|
@ -42,10 +42,13 @@ class BredBrowser(BaseBrowser):
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_logged(self):
|
def is_logged(self):
|
||||||
return not self.is_on_page(LoginPage)
|
return self.page is not None and not self.is_on_page(LoginPage)
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
return self.location('https://www.bred.fr/mylittleform?type=1')
|
if not self.is_logged():
|
||||||
|
self.login()
|
||||||
|
else:
|
||||||
|
self.location('https://www.bred.fr/Andromede/Main')
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
assert isinstance(self.username, basestring)
|
assert isinstance(self.username, basestring)
|
||||||
|
|
@ -56,8 +59,9 @@ class BredBrowser(BaseBrowser):
|
||||||
|
|
||||||
self.page.login(self.username, self.password)
|
self.page.login(self.username, self.password)
|
||||||
|
|
||||||
assert self.is_on_page(LoginResultPage)
|
assert self.is_on_page((LoginResultPage, EmptyPage))
|
||||||
|
|
||||||
|
if self.is_on_page(LoginResultPage):
|
||||||
error = self.page.get_error()
|
error = self.page.get_error()
|
||||||
if error is not None:
|
if error is not None:
|
||||||
raise BrowserIncorrectPassword(error)
|
raise BrowserIncorrectPassword(error)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from mechanize import FormNotFoundError
|
||||||
from decimal import Decimal, InvalidOperation
|
from decimal import Decimal, InvalidOperation
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
@ -39,6 +40,25 @@ class LoginPage(BasePage):
|
||||||
|
|
||||||
|
|
||||||
class LoginResultPage(BasePage):
|
class LoginResultPage(BasePage):
|
||||||
|
def on_loaded(self):
|
||||||
|
for script in self.document.xpath('//script'):
|
||||||
|
text = script.text
|
||||||
|
if text is None:
|
||||||
|
continue
|
||||||
|
m = re.search("window.location.replace\('([^']+)'\);", text)
|
||||||
|
if m:
|
||||||
|
self.browser.location(m.group(1))
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.browser.select_form(name='banque')
|
||||||
|
except FormNotFoundError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.browser.set_all_readonly(False)
|
||||||
|
self.browser['typeCompte'] = 'P'
|
||||||
|
self.browser.submit()
|
||||||
|
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
self.browser.location('MainAuth?typeDemande=AC', no_login=True)
|
self.browser.location('MainAuth?typeDemande=AC', no_login=True)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue