mirror of
https://github.com/spacedeck/spacedeck-open.git
synced 2025-12-17 10:27:32 +01:00
initial commit.
This commit is contained in:
31
middlewares/templates.js
Normal file
31
middlewares/templates.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
require('../models/schema');
|
||||
var config = require('config');
|
||||
var _ = require('underscore');
|
||||
|
||||
module.exports = (req, res, next) => {
|
||||
res.oldRender = res.render;
|
||||
res.render = function(template, params) {
|
||||
|
||||
var team = req.subdomainTeam;
|
||||
if (team) {
|
||||
team = _.pick(team.toObject(), ['_id', 'name', 'subdomain', 'avatar_original_uri']);
|
||||
} else {
|
||||
team = null;
|
||||
}
|
||||
|
||||
const addParams = {
|
||||
locale: req.i18n.locale,
|
||||
config: config,
|
||||
subdomain_team: team,
|
||||
user: req.user,
|
||||
csrf_token: "",
|
||||
socket_auth: req.token
|
||||
};
|
||||
|
||||
const all = _.extend(params, addParams);
|
||||
res.oldRender(template, all);
|
||||
};
|
||||
next();
|
||||
}
|
||||
Reference in New Issue
Block a user