Last active
December 10, 2015 21:58
-
-
Save MACSkeptic/4498671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function authWithCas(req, res) { | |
var CAS = require('cas'); | |
var cas = new CAS({base_url: 'https://cas.thoughtworks.com/cas', service: 'www.recruiting-dashboard.herokuapp.com'}); | |
var ticket = req.param('ticket'); | |
if (ticket) { | |
cas.validate(ticket, function(err, status, username) { | |
if (err) { | |
// Handle the error | |
res.send({error: err}); | |
} | |
else { | |
// Log the user in | |
res.send({status: status, username: username}); | |
} | |
}); | |
} else { | |
res.redirect('https://cas.thoughtworks.com/cas'); | |
} | |
}; | |
//var auth = express.basicAuth('talent', 'dashboard'); | |
//app.get('/', auth, routes.index); | |
//instead of these two lines above | |
app.get('/', authWithCas, routes.index); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment