handle authentication errors
Signed-off-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@gmx.fr>
This commit is contained in:
parent
47823d5b25
commit
a40abf539f
2 changed files with 16 additions and 2 deletions
|
|
@ -21,7 +21,7 @@ from weboob.browser import LoginBrowser, URL, need_login
|
||||||
from weboob.exceptions import BrowserIncorrectPassword
|
from weboob.exceptions import BrowserIncorrectPassword
|
||||||
from weboob.capabilities.bill import Detail
|
from weboob.capabilities.bill import Detail
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from .pages import LoginPage, HomePage, AccountPage, LastPaymentsPage, PaymentDetailsPage, BillsPage
|
from .pages import LoginPage, LoginValidationPage, HomePage, AccountPage, LastPaymentsPage, PaymentDetailsPage, BillsPage
|
||||||
|
|
||||||
__all__ = ['AmeliBrowser']
|
__all__ = ['AmeliBrowser']
|
||||||
|
|
||||||
|
|
@ -30,6 +30,7 @@ class AmeliBrowser(LoginBrowser):
|
||||||
BASEURL = 'https://assure.ameli.fr'
|
BASEURL = 'https://assure.ameli.fr'
|
||||||
|
|
||||||
loginp = URL('/PortailAS/appmanager/PortailAS/assure\?.*_pageLabel=as_login_page', LoginPage)
|
loginp = URL('/PortailAS/appmanager/PortailAS/assure\?.*_pageLabel=as_login_page', LoginPage)
|
||||||
|
login_validationp = URL('https://assure.ameli.fr:443/PortailAS/appmanager/PortailAS/assure;jsessionid=[a-zA-Z0-9!;-]+\?_nfpb=true&_windowLabel=connexioncompte_2&connexioncompte_2_actionOverride=%2Fportlets%2Fconnexioncompte%2Fvalidationconnexioncompte&_pageLabel=as_login_page$', LoginValidationPage)
|
||||||
homep = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_accueil_page', HomePage)
|
homep = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_accueil_page', HomePage)
|
||||||
accountp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_info_perso_page', AccountPage)
|
accountp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_info_perso_page', AccountPage)
|
||||||
billsp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_revele_mensuel_presta_page', BillsPage)
|
billsp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_revele_mensuel_presta_page', BillsPage)
|
||||||
|
|
@ -50,6 +51,10 @@ class AmeliBrowser(LoginBrowser):
|
||||||
|
|
||||||
self.page.login(self.username, self.password)
|
self.page.login(self.username, self.password)
|
||||||
|
|
||||||
|
error = self.page.is_error()
|
||||||
|
if error:
|
||||||
|
raise BrowserIncorrectPassword(error)
|
||||||
|
|
||||||
self.homep.stay_or_go() # Redirection not interpreted by browser. Mannually redirect on homep
|
self.homep.stay_or_go() # Redirection not interpreted by browser. Mannually redirect on homep
|
||||||
|
|
||||||
if not self.homep.is_here():
|
if not self.homep.is_here():
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,12 @@ class AmeliBasePage(HTMLPage):
|
||||||
self.logger.debug('logged: %s' % (logged))
|
self.logger.debug('logged: %s' % (logged))
|
||||||
return logged
|
return logged
|
||||||
|
|
||||||
|
def is_error(self):
|
||||||
|
errors = self.doc.xpath(u'//*[@id="r_errors"]')
|
||||||
|
if errors:
|
||||||
|
return errors[0].text_content()
|
||||||
|
return False
|
||||||
|
|
||||||
class LoginPage(AmeliBasePage):
|
class LoginPage(AmeliBasePage):
|
||||||
def login(self, login, password):
|
def login(self, login, password):
|
||||||
form = self.get_form('//form[@name="connexionCompteForm"]')
|
form = self.get_form('//form[@name="connexionCompteForm"]')
|
||||||
|
|
@ -45,6 +51,9 @@ class LoginPage(AmeliBasePage):
|
||||||
form['connexioncompte_2codeConfidentiel'] = password.encode('utf8')
|
form['connexioncompte_2codeConfidentiel'] = password.encode('utf8')
|
||||||
form.submit()
|
form.submit()
|
||||||
|
|
||||||
|
class LoginValidationPage(AmeliBasePage):
|
||||||
|
pass
|
||||||
|
|
||||||
class HomePage(AmeliBasePage):
|
class HomePage(AmeliBasePage):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue