Skip to content

Commit

Permalink
add req in callback for ip logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien Béchet committed Nov 2, 2017
1 parent be390d6 commit 31f1a28
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loopback-component-cas",
"version": "0.5.0",
"version": "0.5.1",
"description": "Loopback CAS Authentification",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion protocol1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down
2 changes: 1 addition & 1 deletion protocol23.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down

0 comments on commit 31f1a28

Please sign in to comment.