blob: e0daca43c9539c35fe63fefce1caa92b92dd1ba1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
const buildDate = +Date.now();
var middleware = module.exports = {
ensureAuthenticated: function (req, res, next) {
if (! req.isAuthenticated()) {
req.session.returnTo = req.path
return res.redirect('/login')
}
next()
},
ensureLocals: function (req, res, next) {
res.locals.csrfToken = req.csrfToken ? req.csrfToken() : 'csrf'
res.locals.title = "bucky"
res.locals.env = process.env.NODE_ENV
if (req.isAuthenticated()) {
res.locals.show_header = true
res.locals.preload = JSON.stringify({
env: res.locals.env,
buildDate: buildDate,
s3: {
bucket: process.env.S3_BUCKET,
path: process.env.S3_PATH,
}
})
}
else {
res.locals.show_header = false
res.locals.preload = JSON.stringify({
env: res.locals.env,
})
}
next()
},
}
|