         else 
             callback null, false
 
+
+## function checkProxy (auth, callback)
+## @auth {String} Field 'authorization' i request header
+##     Contains application name and password
+## @callback {function} Continuation to pass control back to when complete.
+## Check if application is proxy
+## Useful for register and login requests
 module.exports.checkProxy = (auth, callback) ->
     if auth isnt "undefined" and auth?
         # Recover username and password in field authorization

                permissions[body.name][docType.toLowerCase()] = description



## function init (app, callback)
## @app {Object} application DS, allows to acces variables environment of DS
## @callback {function} Continuation to pass control back to when complete.
## Initialize tokens which contains applications and their tokens
module.exports.init = (app, callback) ->
    token = fs.readFileSync('/etc/cozy/tokens/data-system.token', 'utf8')
    token = token.split('\n')[0]
    tokens['home'] = token
    permissions.home = 
        "application":

## @callback {function} Continuation to pass control back to when complete.
## Check if application can manage docType
module.exports.checkDocType = (auth, docType, callback) ->
    # Check if application is authenticated
    checkToken auth, (err, isAuthenticated, name) =>
        if isAuthenticated
            if docType?
                docType = docType.toLowerCase()
                # Check if application can manage docType
                if permissions[name][docType]?
                    console.log "#{name} is authorized to manage #{docType} "
                    callback null, true, true
