The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit e8cf64e3 authored by Florian Duguet's avatar Florian Duguet Committed by Vincent A

[edfparticulier] wrong password handling has changed a little bit

Closes: 2456@sibi
parent 23960f50
......@@ -50,7 +50,7 @@ class EdfParticulierBrowser(LoginBrowser, StatesMixin):
authorize = URL(r'https://espace-client.edf.fr/sso/oauth2/INTERNET/authorize', AuthorizePage)
wrong_password = URL(
r'https://espace-client.edf.fr/connexion/mon-espace-client/templates/openam/authn/PasswordAuth2.html',
r'https://espace-client.edf.fr/sso/XUI/templates/openam/authn/PasswordAuth2.html',
WrongPasswordPage
)
check_authenticate = URL('/services/rest/openid/checkAuthenticate', CheckAuthenticatePage)
......@@ -170,8 +170,8 @@ def do_login(self):
# should be SetPasAuth2 if password is ok
if self.page.get_data()['stage'] == 'PasswordAuth2':
attempt_number = self.page.get_data()['callbacks'][1]['output'][0]['value']
# attempt_number is the number of wrong password
attempt_number = int(self.page.get_data()['callbacks'][1]['output'][0]['value'])
# attempt_number is the number of wrong password that remains before blocking
msg = self.wrong_password.go().get_wrongpass_message(attempt_number)
raise BrowserIncorrectPassword(msg)
......
......@@ -26,7 +26,7 @@
from woob.browser.filters.html import Attr
from woob.browser.pages import LoggedPage, JsonPage, HTMLPage, RawPage
from woob.browser.filters.standard import Env, Format, Date, Eval, CleanText, Regexp
from woob.browser.filters.standard import Env, Format, Date, Eval, CleanText
from woob.browser.elements import ItemElement, DictElement, method
from woob.browser.filters.json import Dict
from woob.capabilities.bill import Bill, Subscription
......@@ -63,15 +63,16 @@ class WrongPasswordPage(HTMLPage):
def get_wrongpass_message(self, attempt_number):
# edf website block access after 5 wrong password, and user will have to change his password
# this is very important because it can tell to user how much attempt it remains
script = CleanText('//script[contains(text(), "Mot de passe incorrect")]')
msg = CleanText('//p[@id="error1"]')(self.doc)
msg_remain_attemp = CleanText('//p[strong[@id="attempt-number"]]', default='')(self.doc)
msg_remain_attemp = msg_remain_attemp.replace('{{theme.settings.spaceName.texte}} ', '')
if attempt_number > 0:
return Format(
'%s %s %s',
Regexp(script, r">(Mot de passe incorrect.*?)<"),
CleanText('//div[@class="arrow_box--content"]', children=False), int(attempt_number)
)(self.doc)
return Regexp(script, r">(Vous avez atteint.*?)<")(self.doc)
msg += ' ' + msg_remain_attemp.replace(
'Tentatives restantes : X', 'Tentatives restantes : %d' % attempt_number
)
return msg
class OTPTemplatePage(HTMLPage):
......
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