diff --git a/README.md b/README.md index 217d192..11d96cd 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ established by [Joseph Smarr][schema-author]. Attributes can be any key from `${userModel}.profile`. -If optional `loginCallback(service, user)` exist, `loopback-component-cas` call it when login occure. +If optional `loginCallback(req, service, user)` exist, `loopback-component-cas` call it when login occure. ### Specific case diff --git a/index.js b/index.js index 315709f..c76b0b1 100644 --- a/index.js +++ b/index.js @@ -15,9 +15,10 @@ module.exports = function (loopbackApplication, options) { options.userModel = "User" } - let loginCallback = options.loginCallback || function(service, user) { + let loginCallback = options.loginCallback || function(req, service, user) { let loginOk = { 'loopback-component': 'cas', + 'ip': req.ip, 'service': service.name, 'email': user.email } diff --git a/package-lock.json b/package-lock.json index 2382af0..fa74e6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "loopback-component-cas", - "version": "0.4.0", + "version": "0.5.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e4f18bb..11bd748 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "loopback-component-cas", - "version": "0.5.0", + "version": "0.5.1", "description": "Loopback CAS Authentification", "main": "index.js", "scripts": { diff --git a/protocol1.js b/protocol1.js index cf6e201..cf4957c 100644 --- a/protocol1.js +++ b/protocol1.js @@ -50,7 +50,7 @@ module.exports = function (app, config, req, res, next, loginCallback) { })) } debug('CAS1 validate (email: %s, service: %s)', user.email, service.name) - loginCallback(service, user); + loginCallback(req, service, user); return res.send('yes\n') }) diff --git a/protocol23.js b/protocol23.js index 13d4118..afe03dd 100644 --- a/protocol23.js +++ b/protocol23.js @@ -245,7 +245,7 @@ module.exports = function (app, config, req, res, next, loginCallback, isProtoco getAttributes(app, config, user, tgt).then(function(returnProfile){ let casversion = isProtocol3?'3':'2' debug('CAS%d validate (email:%s, service: %s)', casversion, user.email, service.name) - loginCallback(service, user); + loginCallback(req, service, user); /* 'TARGET' in req.query ? -> SAML */ if (req.query['TARGET']) {