Basic support for Mosaico-based email templates.

This commit is contained in:
Tomas Bures 2018-04-02 11:58:32 +02:00
parent b5cdf57f72
commit 7b5642e911
38 changed files with 1271 additions and 751 deletions

View file

@ -75,7 +75,7 @@ module.exports.csrfProtection = csrf({
module.exports.parseForm = bodyParser.urlencoded({
extended: false,
limit: config.www.postsize
limit: config.www.postSize
});
module.exports.loggedIn = (req, res, next) => {
@ -87,35 +87,45 @@ module.exports.loggedIn = (req, res, next) => {
};
module.exports.authByAccessToken = (req, res, next) => {
nodeifyPromise((async () => {
if (!req.query.access_token) {
if (!req.query.access_token) {
res.status(403);
res.json({
error: 'Missing access_token',
data: []
});
}
users.getByAccessToken(req.query.access_token).then(user => {
req.user = user;
next();
}).catch(err => {
if (err instanceof interoperableErrors.PermissionDeniedError) {
res.status(403);
return res.json({
error: 'Missing access_token',
res.json({
error: 'Invalid or expired access_token',
data: []
});
} else {
res.status(500);
res.json({
error: err.message || err,
data: []
});
}
});
};
try {
const user = await users.getByAccessToken(req.query.access_token);
module.exports.tryAuthByRestrictedAccessToken = (req, res, next) => {
if (req.cookies.restricted_access_token) {
users.getByRestrictedAccessToken(req.cookies.restricted_access_token).then(user => {
req.user = user;
next();
} catch (err) {
if (err instanceof interoperableErrors.NotFoundError) {
res.status(403);
return res.json({
error: 'Invalid or expired access_token',
data: []
});
} else {
res.status(500);
return res.json({
error: err.message || err,
data: []
});
}
}
})(), next);
}).catch(err => {
next();
});
} else {
next();
}
};
module.exports.setup = app => {