Skip to content
This repository has been archived by the owner on Oct 26, 2019. It is now read-only.

Commit

Permalink
Use url.format
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfrg committed Oct 17, 2016
1 parent dadcad9 commit 9f06c7a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/auth-auth0.js
Expand Up @@ -8,6 +8,7 @@
* https://github.com/jupyter-incubator/dashboards_server/wiki/Authentication
* for details.
*/
var url = require('url');
var config = require('./config');
var passport = require('passport');
var Auth0Strategy = require('passport-auth0');
Expand All @@ -18,7 +19,7 @@ module.exports = function(app) {
passport.authenticate('auth0', { failureRedirect: '/login' }),
function(req, res) {
if (!req.user) {
throw new Error('user null');
throw new Error('User name must be set');
}
res.redirect("/");
}
Expand All @@ -31,7 +32,16 @@ module.exports = function(app) {

app.post('/logout', function(req, res){
req.logout();
res.redirect('https://' + config.get('AUTH0_DOMAIN') + '/v2/logout?returnTo=' + config.get('PUBLIC_LINK_PATTERN') + '&client_id=' + config.get('AUTH0_CLIENT_ID'));
var logout_obj_url = {
host: config.get('AUTH0_DOMAIN'),
pathname: '/v2/logout',
query: {
'returnTo': config.get('PUBLIC_LINK_PATTERN'),
'client_id': config.get('AUTH0_CLIENT_ID'),
}
};
var logout_url = url.format(logout_obj_url);
res.redirect(logout_url);
});

var strategy = new Auth0Strategy({
Expand Down

0 comments on commit 9f06c7a

Please sign in to comment.