 
 # Layer to login to Numéricable website.
 logIn = (requiredFields, billInfos, data, next) ->
-    monCompteUrl = "https://moncompte.numericable.fr"
-    connexionUrl = "https://connexion.numericable.fr"
+    accountUrl = "https://moncompte.numericable.fr"
+    connectionUrl = "https://connexion.numericable.fr"
     appKeyOptions =
         method: 'GET'
         jar: true
-        url: "#{monCompteUrl}/pages/connection/Login.aspx"
+        url: "#{accountUrl}/pages/connection/Login.aspx"
 
     logInOptions =
         method: 'POST'
         jar: true
-        url: "#{connexionUrl}/Oauth/Oauth.php"
+        url: "#{connectionUrl}/Oauth/Oauth.php"
         form:
             'action': "connect"
-            'linkSSO': "#{connection}/pages/connection/Login.aspx?link=HOME"
+            'linkSSO': "#{connectionUrl}/pages/connection/Login.aspx?link=HOME"
             'appkey': ""
             'isMobile': ""
 
     redirectOptions =
         method: 'POST'
         jar: true
-        url: connexionUrl
+        url: connectionUrl
 
     signInOptions =
         method: 'POST'
         jar: true
-        url: "#{connexionUrl}/Oauth/login/"
+        url: "#{connectionUrl}/Oauth/login/"
         form:
             'login': requiredFields.login
             'pwd': requiredFields.password


        bills.fetched.push bill if bill.date? and bill.amount? and bill.pdfurl?

    log.info "#{bills.fetched.length} bills retrieved"

    if not bills.fetched.length
        next "No bills retrieved"
    else
        next()

        request logInOptions, (err, res, body) ->
            if err
                log.error 'Login failed'
                return next "error occurred during import."

            log.info 'Signing in'
            request signInOptions, (err, res, body) ->
                if err
                    log.error 'Signin failed'
                    return next "bad credentials"

                redirectUrl = res.headers.location
                if not redirectUrl
                    return next "Could not retrieve redirect URL"

                redirectOptions.url += redirectUrl

                log.info "Fetching access token"
                request redirectOptions, (err, res, body) ->
                    accessToken = ""

                    if not err
                        $ = cheerio.load body
                        accessToken = $("#accessToken").attr "value"

                    if not accessToken
                        log.error 'Token fetching failed'
                        return next "error occurred during import."

                    tokenAuthOptions.qs.accessToken = accessToken

