aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.js38
-rw-r--r--config/express.js6
-rw-r--r--config/middlewares/authorization.js2
-rw-r--r--config/passport.js8
-rw-r--r--config/routes.js4
5 files changed, 28 insertions, 30 deletions
diff --git a/config/config.js b/config/config.js
index 3637cf3..c7ff42a 100644
--- a/config/config.js
+++ b/config/config.js
@@ -4,26 +4,26 @@ var path = require('path')
module.exports = {
development: {
- db: 'mongodb://localhost/Divid',
- root: rootPath,
- app: {
+ db: 'mongodb://localhost/Divid'
+ , root: rootPath
+ , app: {
name: 'Divid'
- },
- facebook: {
- clientID: '504825706245603',
- clientSecret: 'e5ea0faed85d8749cafd38732530ef35',
- callbackURL: 'https://divid.no/auth/facebook/callback'
- },
- twitter: {
- clientID: 'tpCfKBUyAfogTpFxnb9w',
- clientSecret: 'abzInK4Nu0IFUhyXl73O2XjlFLFlzmBtLmbXk6v8',
- callbackURL: 'https://divid.no/auth/twitter/callback'
- },
- email: {
- server: 'localhost',
- ssl: false
- },
- sessionSecret: 'lsdrghoi4hgqio42nqf2uqi32f3bilu23fl23b',
+ }
+ , facebook: {
+ clientID: '504825706245603'
+ , clientSecret: 'e5ea0faed85d8749cafd38732530ef35'
+ , callbackURL: 'https://divid.no/auth/facebook/callback'
+ }
+ , twitter: {
+ clientID: 'tpCfKBUyAfogTpFxnb9w'
+ , clientSecret: 'abzInK4Nu0IFUhyXl73O2XjlFLFlzmBtLmbXk6v8'
+ , callbackURL: 'https://divid.no/auth/twitter/callback'
+ }
+ , email: {
+ server: 'localhost'
+ , ssl: false
+ }
+ , sessionSecret: 'lsdrghoi4hgqio42nqf2uqi32f3bilu23fl23b'
}
}
diff --git a/config/express.js b/config/express.js
index a281123..d9d4633 100644
--- a/config/express.js
+++ b/config/express.js
@@ -33,8 +33,8 @@ module.exports = function (app, config, passport) {
app.use(express.session({ secret: config.sessionSecret }));
// use passport session
- app.use(passport.initialize());
- app.use(passport.session());
+ app.use(passport.initialize()); // initializes passport, our login module
+ app.use(passport.session()); // With sessions!
app.use(express.favicon(__dirname + '/public/favicon.ico'));
@@ -43,6 +43,8 @@ module.exports = function (app, config, passport) {
app.use(app.router);
+ // If no routes are triggered, we reach these babies:
+
app.use(function(err, req, res, next) {
if (~err.message.indexOf('not found')) return next(); // treat like 404
diff --git a/config/middlewares/authorization.js b/config/middlewares/authorization.js
index b881a3d..6726f8b 100644
--- a/config/middlewares/authorization.js
+++ b/config/middlewares/authorization.js
@@ -1,4 +1,4 @@
-
+// AUTH Middleware. This is what checks if you are logged in.
/*
* Generic require login routing
diff --git a/config/passport.js b/config/passport.js
index e0be2d9..ae8d34a 100644
--- a/config/passport.js
+++ b/config/passport.js
@@ -37,7 +37,7 @@ module.exports = function (passport, config) {
if (err) return done(err);
if (!user) return done(null, false, { message: 'Unknown user' });
if (!user.authenticate(password)) return done(null, false, { message: 'Invalid password' });
- return done(null, user);
+ return done(null, user); // yay!
});
}));
@@ -48,7 +48,7 @@ module.exports = function (passport, config) {
User.findOne({ _id: access.user }, function(err, user) {
if (err) return done(err);
if (!user) return done(null, false, { message: 'Unknown user' });
- return done(null, user);
+ return done(null, user); // yay!
});
});
}));
@@ -115,9 +115,5 @@ module.exports = function (passport, config) {
}));
-
-
-
-
}
diff --git a/config/routes.js b/config/routes.js
index 8ba83a9..8f5865a 100644
--- a/config/routes.js
+++ b/config/routes.js
@@ -32,7 +32,7 @@ module.exports = function(app, passport, auth) {
app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/' }), users.signin);
app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/' }), users.authCallback);
- app.get('/invite/:randomToken', users.claimInvite);
+ app.get('/invite/:randomToken', users.claimInvite); // :randomToken can be retrieved in 'req.params.randomToken'
app.post('/invite/:randomToken', users.postClaimInvite);
@@ -40,12 +40,12 @@ module.exports = function(app, passport, auth) {
app.get('/login/:hash', passport.authenticate('hash', { failureRedirect: '/'}), users.randomLogin);
+
/**
* REQUIRES LOGIN
* ============================================================
*/
-
app.get('/dashboard', auth.requiresLogin, system.dashboard);
app.get('/registerEmail', auth.requiresLogin, users.registerEmail);