                         'auth-method': OAUTH_VERSION
                         'auth-endpoint': "#{host}/apps/remotestorage/oauth/"
 
-                link.properties[OAUTH_VERSION] = link.properties['auth-endpoint']
+                authEndPoint = link.properties['auth-endpoint']
+                link.properties[OAUTH_VERSION] = authEndPoint
 
                 accountInfo.links.push link
 
             return res.send 200, accountInfo
 
-    else
-        res.send 404
+        else
+            res.send 404

# OpenID provider, public email, public tel, ...
module.exports.webfingerAccount = (req, res, next) ->

    if req.params.module is 'caldav' or req.params.module is 'carddav'
        res.redirect '/public/sync/'

    else if req.params.module is 'webfinger'

        CozyInstance.first (err, instance) ->

            return next err if err
            return next new Error('no instance') unless instance?.domain

            host = 'https://' + instance.domain
            OAUTH_VERSION = 'http://tools.ietf.org/html/rfc6749#section-4.2'
            PROTOCOL_VERSION = 'draft-dejong-remotestorage-01'


CozyInstance = require '../models/instance'
router = require '../lib/router'

# Return the host meta file
# support only JSON format
