Commit 30c2081f authored by thibault douge's avatar thibault douge Committed by Vincent A

[ameli] add necessary _ct value in form login

Closes: 65329@sibi 47711@sibi
parent 5bd6c52a
Pipeline #3258 passed with stages
in 24 minutes and 38 seconds
......@@ -26,7 +26,10 @@ from dateutil.relativedelta import relativedelta
from weboob.browser import LoginBrowser, URL, need_login
from weboob.exceptions import ActionNeeded
from .pages import ErrorPage, LoginPage, RedirectPage, CguPage, SubscriptionPage, DocumentsPage
from .pages import (
ErrorPage, LoginPage, RedirectPage, CguPage,
SubscriptionPage, DocumentsPage, CtPage,
class AmeliBrowser(LoginBrowser):
......@@ -38,10 +41,13 @@ class AmeliBrowser(LoginBrowser):
cgu_page = URL(r'/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_conditions_generales_page.*', CguPage)
subscription_page = URL(r'/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_info_perso_page.*', SubscriptionPage)
documents_page = URL(r'/PortailAS/', DocumentsPage)
ct_page = URL(r'/PortailAS/JavaScriptServlet', CtPage)
def do_login(self):
self.login_page.go(), self.password)
# _ct value is necessary for the login
_ct ='POST', headers={'FETCH-CSRF-TOKEN': '1'}).get_ct_value(), self.password, _ct)
if self.cgu_page.is_here():
raise ActionNeeded(
......@@ -19,11 +19,12 @@
from __future__ import unicode_literals
import re
from weboob.browser.elements import method, ListElement, ItemElement
from weboob.browser.filters.html import Link
from weboob.browser.filters.standard import CleanText, Regexp, CleanDecimal, Currency, Field, Format, Env
from weboob.browser.pages import LoggedPage, HTMLPage, PartialHTMLPage
from weboob.browser.pages import LoggedPage, HTMLPage, PartialHTMLPage, RawPage
from weboob.capabilities.bill import Subscription, Bill
from weboob.exceptions import BrowserUnavailable
from import parse_french_date
......@@ -31,13 +32,20 @@ from import json
class LoginPage(HTMLPage):
def login(self, username, password):
def login(self, username, password, _ct):
form = self.get_form(id='connexioncompte_2connexionCompteForm')
form['connexioncompte_2numSecuriteSociale'] = username
form['connexioncompte_2codeConfidentiel'] = password
form['_ct'] = _ct
class CtPage(RawPage):
# the page contains only _ct value
def get_ct_value(self):
return'_ct:(.*)', self.text).group(1)
class RedirectPage(LoggedPage, HTMLPage):
REFRESH_XPATH = '//meta[@http-equiv="refresh"]'
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