Baris Usakli 11 years ago
commit 56b618c915

@ -24,6 +24,8 @@
if (err) { if (err) {
winston.error('filter:auth.init - plugin failure'); winston.error('filter:auth.init - plugin failure');
} }
Auth.createRoutes(Auth.app);
}); });
}); });
@ -31,7 +33,7 @@
passport.use(new passportTwitter({ passport.use(new passportTwitter({
consumerKey: meta.config['social:twitter:key'], consumerKey: meta.config['social:twitter:key'],
consumerSecret: meta.config['social:twitter:secret'], consumerSecret: meta.config['social:twitter:secret'],
callbackURL: nconf.get('url') + 'auth/twitter/callback' callbackURL: 'auth/twitter/callback'
}, function(token, tokenSecret, profile, done) { }, function(token, tokenSecret, profile, done) {
login_module.loginViaTwitter(profile.id, profile.username, profile.photos, function(err, user) { login_module.loginViaTwitter(profile.id, profile.username, profile.photos, function(err, user) {
if (err) { if (err) {
@ -44,7 +46,7 @@
login_strategies.push({ login_strategies.push({
name: 'twitter', name: 'twitter',
url: '/auth/twitter', url: '/auth/twitter',
callbackURL: nconf.get('url') + '/auth/twitter/callback', callbackURL: '/auth/twitter/callback',
icon: 'twitter', icon: 'twitter',
scope: '' scope: ''
}); });
@ -54,7 +56,7 @@
passport.use(new passportGoogle({ passport.use(new passportGoogle({
clientID: meta.config['social:google:id'], clientID: meta.config['social:google:id'],
clientSecret: meta.config['social:google:secret'], clientSecret: meta.config['social:google:secret'],
callbackURL: nconf.get('url') + 'auth/google/callback' callbackURL: 'auth/google/callback'
}, function(accessToken, refreshToken, profile, done) { }, function(accessToken, refreshToken, profile, done) {
login_module.loginViaGoogle(profile.id, profile.displayName, profile.emails[0].value, function(err, user) { login_module.loginViaGoogle(profile.id, profile.displayName, profile.emails[0].value, function(err, user) {
if (err) { if (err) {
@ -116,6 +118,10 @@
return login_strategies; return login_strategies;
} }
Auth.registerApp = function(app) {
Auth.app = app;
}
Auth.createRoutes = function(app) { Auth.createRoutes = function(app) {
app.post('/logout', function(req, res) { app.post('/logout', function(req, res) {
if (req.user && req.user.uid > 0) { if (req.user && req.user.uid > 0) {

@ -348,7 +348,7 @@ var path = require('path'),
app.namespace(nconf.get('relative_path'), function () { app.namespace(nconf.get('relative_path'), function () {
auth.createRoutes(app); auth.registerApp(app);
admin.createRoutes(app); admin.createRoutes(app);
userRoute.createRoutes(app); userRoute.createRoutes(app);
apiRoute.createRoutes(app); apiRoute.createRoutes(app);

Loading…
Cancel
Save