Skip to content

Commit

Permalink
past session to locals
Browse files Browse the repository at this point in the history
  • Loading branch information
xjsender committed Mar 22, 2015
1 parent 44010a7 commit 7e7fb2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
7 changes: 5 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ var express = require("express")
, path = require('path')
, jsforce = require("jsforce")
, underscore = require("underscore")
, webRouter = require("./routers/web_router")
, webRouter = require("./routes/web_router")
, session = require("express-session")
, bodyParser = require("body-parser")
, router = express.Router()
, app = express();

app.set("view engine", "html");
Expand All @@ -24,7 +25,9 @@ app.use(bodyParser.urlencoded({
extended: true
}));

app.use('/', webRouter);
// app.use('/', webRouter);
webRouter(app);
app.use(router);

var server = app.listen(process.env.PORT || 3000, function() {
var host = server.address().address
Expand Down
13 changes: 0 additions & 13 deletions routers/web_router.js

This file was deleted.

18 changes: 18 additions & 0 deletions routes/web_router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var express = require("express")
, site = require("../controller/site")
, account = require("../controller/account")
, router = express.Router()

module.exports = function(app) {
app.use(function(req, res, next) {
res.locals.session = req.session;
next();
});

app.get('/', site.index);
app.post('/login', site.login);
app.get('/about', site.about);
app.get('/oauth/callback', site.callback);
app.get('/account/o', account.list);
app.get('/account/:id', account.view);
}
1 change: 1 addition & 0 deletions views/about.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<% include ./template/header.html %>
<div class="container">
<h1>About</h1>
<%- JSON.stringify(session) %>
</div>
<% include ./template/footer.html %>

0 comments on commit 7e7fb2f

Please sign in to comment.