sgpe: Proper handling of login failure
Would create an infinite loop
This commit is contained in:
parent
caa84dbf2c
commit
af824fde0f
2 changed files with 11 additions and 5 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
from weboob.tools.ordereddict import OrderedDict
|
from weboob.tools.ordereddict import OrderedDict
|
||||||
|
|
||||||
from .pages import LoginPage, AccountsPage, HistoryPage
|
from .pages import LoginPage, ErrorPage, AccountsPage, HistoryPage
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['SGProfessionalBrowser', 'SGEnterpriseBrowser']
|
__all__ = ['SGProfessionalBrowser', 'SGEnterpriseBrowser']
|
||||||
|
|
@ -35,6 +35,7 @@ class SGPEBrowser(BaseBrowser):
|
||||||
self.PAGES = OrderedDict((
|
self.PAGES = OrderedDict((
|
||||||
('%s://%s/Pgn/.+PageID=SoldeV3&.+' % (self.PROTOCOL, self.DOMAIN), AccountsPage),
|
('%s://%s/Pgn/.+PageID=SoldeV3&.+' % (self.PROTOCOL, self.DOMAIN), AccountsPage),
|
||||||
('%s://%s/Pgn/.+PageID=ReleveCompteV3&.+' % (self.PROTOCOL, self.DOMAIN), HistoryPage),
|
('%s://%s/Pgn/.+PageID=ReleveCompteV3&.+' % (self.PROTOCOL, self.DOMAIN), HistoryPage),
|
||||||
|
('%s://%s/authent\.html' % (self.PROTOCOL, self.DOMAIN), ErrorPage),
|
||||||
('%s://%s/' % (self.PROTOCOL, self.DOMAIN), LoginPage),
|
('%s://%s/' % (self.PROTOCOL, self.DOMAIN), LoginPage),
|
||||||
))
|
))
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
|
|
@ -61,12 +62,12 @@ class SGPEBrowser(BaseBrowser):
|
||||||
|
|
||||||
# force page change
|
# force page change
|
||||||
if not self.is_on_page(AccountsPage):
|
if not self.is_on_page(AccountsPage):
|
||||||
self.accounts()
|
self.accounts(no_login=True)
|
||||||
if self.is_on_page(LoginPage):
|
if not self.is_logged():
|
||||||
raise BrowserIncorrectPassword()
|
raise BrowserIncorrectPassword()
|
||||||
|
|
||||||
def accounts(self):
|
def accounts(self, no_login=False):
|
||||||
self.location('/Pgn/NavigationServlet?PageID=SoldeV3&MenuID=%s&Classeur=1&NumeroPage=1' % self.MENUID)
|
self.location('/Pgn/NavigationServlet?PageID=SoldeV3&MenuID=%s&Classeur=1&NumeroPage=1' % self.MENUID, no_login=no_login)
|
||||||
|
|
||||||
def history(self, _id, page=1):
|
def history(self, _id, page=1):
|
||||||
if page > 1:
|
if page > 1:
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,11 @@ class SGPEPage(BasePage):
|
||||||
return err[0].text.strip()
|
return err[0].text.strip()
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorPage(SGPEPage):
|
||||||
|
def get_error(self):
|
||||||
|
return SGPEPage.get_error(self) or 'Unknown error'
|
||||||
|
|
||||||
|
|
||||||
class LoginPage(SGPEPage):
|
class LoginPage(SGPEPage):
|
||||||
def login(self, login, password):
|
def login(self, login, password):
|
||||||
DOMAIN = self.browser.DOMAIN
|
DOMAIN = self.browser.DOMAIN
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue