Commit 424bd09c authored by Florian Duguet's avatar Florian Duguet Committed by ntome

[orange] handle password page when password is too weak and user has to change it

Closes 38539@sibi
parent 95195ab4
......@@ -22,9 +22,9 @@ from __future__ import unicode_literals
from requests.exceptions import ConnectTimeout
from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded, BrowserPasswordExpired
from .pages import LoginPage, BillsPage
from .pages.login import ManageCGI, HomePage
from .pages.login import ManageCGI, HomePage, PasswordPage
from .pages.bills import SubscriptionsPage, BillsApiProPage, BillsApiParPage, ContractsPage
from .pages.profile import ProfilePage
from weboob.browser.exceptions import ClientError, ServerError
......@@ -41,6 +41,7 @@ class OrangeBillBrowser(LoginBrowser):
home_page = URL('https://businesslounge.orange.fr/$', HomePage)
loginpage = URL('https://login.orange.fr/\?service=sosh&return_url=https://www.sosh.fr/',
'https://login.orange.fr/front/login', LoginPage)
password_page = URL(r'https://login.orange.fr/front/password', PasswordPage)
contracts = URL('https://espaceclientpro.orange.fr/api/contracts\?page=1&nbcontractsbypage=15', ContractsPage)
......@@ -80,6 +81,11 @@ class OrangeBillBrowser(LoginBrowser):
raise BrowserIncorrectPassword(error.response.json())
raise
if self.password_page.is_here():
error_message = self.page.get_change_password_message()
if error_message:
raise BrowserPasswordExpired(error_message)
def get_nb_remaining_free_sms(self):
raise NotImplementedError()
......
......@@ -17,8 +17,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.browser.pages import HTMLPage, LoggedPage
import lxml.html as html
from StringIO import StringIO
from weboob.browser.pages import HTMLPage, LoggedPage, JsonPage
from weboob.tools.json import json
from weboob.browser.filters.standard import CleanText, Format
......@@ -39,6 +44,31 @@ class LoginPage(HTMLPage):
self.browser.location('https://login.orange.fr/front/password', json=json_data)
class PasswordPage(JsonPage):
def get_change_password_message(self):
if self.doc.get('stage') != 'changePassword':
# when stage is not present everything is okay, and if it's not changePassword we prefer do nothing here
return
if 'mandatory' not in self.doc['options']:
# maybe there are some cases where it's optional
return
encoding = self.encoding
if encoding == 'latin-1':
encoding = 'latin1'
if encoding:
encoding = encoding.replace('ISO8859_', 'ISO8859-')
parser = html.HTMLParser(encoding=encoding)
html_doc = html.parse(StringIO(self.doc['view']), parser)
# message should be:
# Votre mot de passe actuel n’est pas suffisamment sécurisé et doit être renforcé.
# Veuillez le modifier pour accéder à vos services Orange.
return CleanText('//p[@id="cnMsg"]')(html_doc)
class ManageCGI(HTMLPage):
pass
......
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