Commit 999f7ce8 authored by Florian Duguet's avatar Florian Duguet Committed by ntome

[bouygues] manage wrong password

Closes: 43238@sibi
parent 9f9749bd
......@@ -24,11 +24,12 @@ from jose import jwt
from weboob.browser import LoginBrowser, URL, need_login
from weboob.browser.exceptions import HTTPNotFound
from weboob.exceptions import BrowserIncorrectPassword
from weboob.tools.compat import urlparse, parse_qsl
from .pages import (
LoginPage, AppConfigPage, SubscriberPage, SubscriptionPage, SubscriptionDetail, DocumentPage, DocumentDownloadPage,
DocumentFilePage,
LoginPage, ForgottenPasswordPage, AppConfigPage, SubscriberPage, SubscriptionPage, SubscriptionDetail, DocumentPage,
DocumentDownloadPage, DocumentFilePage,
)
......@@ -43,6 +44,7 @@ class BouyguesBrowser(LoginBrowser):
BASEURL = 'https://api.bouyguestelecom.fr'
login_page = URL(r'https://www.mon-compte.bouyguestelecom.fr/cas/login', LoginPage)
forgotten_password_page = URL(r'https://www.mon-compte.bouyguestelecom.fr/mon-compte/mot-de-passe-oublie', ForgottenPasswordPage)
app_config = URL(r'https://www.bouyguestelecom.fr/mon-compte/data/app-config.json', AppConfigPage)
subscriber_page = MyURL(r'/personnes/(?P<id_personne>\d+)$', SubscriberPage)
subscriptions_page = MyURL(r'/personnes/(?P<id_personne>\d+)/comptes-facturation', SubscriptionPage)
......@@ -61,6 +63,15 @@ class BouyguesBrowser(LoginBrowser):
self.login_page.go()
self.page.login(self.username, self.password, self.lastname)
if self.login_page.is_here():
msg = self.page.get_error_message()
raise BrowserIncorrectPassword(msg)
if self.forgotten_password_page.is_here():
# when too much attempt has been done in a short time, bouygues redirect us here,
# but no message is available on this page
raise BrowserIncorrectPassword()
# q is timestamp millisecond
self.app_config.go(params={'q': int(time()*1000)})
client_id = self.page.get_client_id()
......
......@@ -27,7 +27,7 @@ from weboob.browser.filters.json import Dict
from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage, RawPage
from weboob.capabilities import NotAvailable
from weboob.capabilities.bill import Subscription, Bill
from weboob.browser.filters.standard import Date, CleanDecimal, Env, Format, Coalesce
from weboob.browser.filters.standard import Date, CleanDecimal, Env, Format, Coalesce, CleanText
from weboob.exceptions import BrowserIncorrectPassword
......@@ -44,6 +44,13 @@ class LoginPage(HTMLPage):
form.submit()
def get_error_message(self):
return CleanText('//div[@id="alert_msg"]')(self.doc)
class ForgottenPasswordPage(HTMLPage):
pass
class AppConfigPage(JsonPage):
def get_client_id(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment