|
|
@@ -19,8 +19,10 @@ module.exports = function(crowi, app) {
|
|
|
, i18nMiddleware = require('i18next-express-middleware')
|
|
|
, i18nUserSettingDetector = require('../util/i18nUserSettingDetector')
|
|
|
, env = crowi.node_env
|
|
|
+ , config = crowi.getConfig()
|
|
|
, middleware = require('../util/middlewares')
|
|
|
|
|
|
+ , Config = crowi.model('Config')
|
|
|
, User = crowi.model('User')
|
|
|
;
|
|
|
|
|
|
@@ -47,7 +49,6 @@ module.exports = function(crowi, app) {
|
|
|
app.use(function(req, res, next) {
|
|
|
var now = new Date()
|
|
|
, baseUrl
|
|
|
- , config = crowi.getConfig()
|
|
|
, tzoffset = -(config.crowi['app:timezone'] || 9) * 60 // for datez
|
|
|
, Page = crowi.model('Page')
|
|
|
, User = crowi.model('User')
|
|
|
@@ -98,7 +99,6 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
// Set basic auth middleware
|
|
|
app.use(function(req, res, next) {
|
|
|
- var config = crowi.getConfig();
|
|
|
if (req.query.access_token || req.body.access_token) {
|
|
|
return next();
|
|
|
}
|
|
|
@@ -113,8 +113,11 @@ module.exports = function(crowi, app) {
|
|
|
});
|
|
|
|
|
|
// passport
|
|
|
- app.use(passport.initialize());
|
|
|
- app.use(passport.session());
|
|
|
+ if (Config.isEnabledPassport(config)) {
|
|
|
+ debug('initialize Passport')
|
|
|
+ app.use(passport.initialize());
|
|
|
+ app.use(passport.session());
|
|
|
+ }
|
|
|
|
|
|
app.use(flash());
|
|
|
|
|
|
@@ -122,8 +125,14 @@ module.exports = function(crowi, app) {
|
|
|
app.use(middleware.swigFunctions(crowi, app));
|
|
|
|
|
|
app.use(middleware.csrfKeyGenerator(crowi, app));
|
|
|
- // app.use(middleware.loginChecker(crowi, app));
|
|
|
- app.use(middleware.loginCheckerForPassport(crowi, app));
|
|
|
+
|
|
|
+ // switch loginChecker
|
|
|
+ if (Config.isEnabledPassport(config)) {
|
|
|
+ app.use(middleware.loginCheckerForPassport(crowi, app));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ app.use(middleware.loginChecker(crowi, app));
|
|
|
+ }
|
|
|
|
|
|
app.use(i18nMiddleware.handle(i18next));
|
|
|
};
|