Initial Commit

This commit is contained in:
2018-09-13 21:15:47 +02:00
commit 09f406cba7
84 changed files with 6920 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
module.exports = (req, res, next) => {
if (res.marko) {
res.markoAsync = async(template, input) => {
const locals = Object.assign((res.locals || {}), input)
for (const key in locals) {
const value = locals[key]
if (value instanceof Promise) {
locals[key] = await value
}
}
return res.marko(template, locals)
}
}
if (req.user) {
res.locals.user = {
loggedIn: true,
name: req.user._json.name,
}
} else {
res.locals.user = {
loggedIn: false,
}
}
next()
}
+29
View File
@@ -0,0 +1,29 @@
const Auth0Strategy = require("passport-auth0")
const passport = require("passport")
const config = require("../config")
//passport-auth0
const strategy = new Auth0Strategy({
domain: config.auth0.domain,
clientID: config.auth0.clientId,
clientSecret: config.auth0.secret, // Replace this with the client secret for your app
callbackURL: config.root + "/auth/callback"
}, (accessToken, refreshToken, extraParams, profile, done) => {
// accessToken is the token to call Auth0 API (not needed in the most cases)
// extraParams.id_token has the JSON Web Token
// profile has all the information from the user
return done(null, profile);
}
)
passport.use(strategy)
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
module.exports = passport
+15
View File
@@ -0,0 +1,15 @@
const session = require("express-session")
const config = require("../config")
var RedisStore = require('connect-redis')(session);
var sess = {
secret: config.session.secret,
store: new RedisStore(config.redis),
cookie: {},
resave: false,
saveUninitialized: true,
}
sess.cookie.secure = config.session.secure
module.exports = session(sess)