         return next err if err
 
         if body.status? and body.status is 'error'
-            return next new Error(body.status_details)
-
-        $ = cheerio.load body
-        entries.csrfToken = $('#loginCsrfParam-login').val()
-        entries.accountName = requiredFields.login
-        log.info 'Tokens retrieved'
-        next()
+            next new Error(body.status_details)
+        else
+            $ = cheerio.load body
+            entries.csrfToken = $('#loginCsrfParam-login').val()
+            entries.accountName = requiredFields.login
+            log.info 'Tokens retrieved'
+            next()
 
 
 # Make the login request with the user inputs (login/password) and the csrf


    Contact.all (err, contacts) ->
        return next err if err
        entries.cozyContacts = contacts
        entries.ofAccountByIds = {}
        for contact in contacts
            account = contact.getAccount ACCOUNT_TYPE, entries.accountName
            if account?
                entries.ofAccountByIds[account.id] = contact

        return next err if err
        if body.status? and body.status is 'error'
            return next new Error(body.status_details)

        entries.listContacts = body.contacts
        if not entries.listContacts?
            next new Error("Error retrieving contacts from request")
        else
            log.info 'List contact OK'
            next()


# Retrieve a list of all Cozy contacts, find all the contacts linked to the
