Files
spacedeck-open/middlewares/api_helpers.js
mntmn 0c5fa597e8 Allow embedding of folders and access to folders to anonymous editors with edit_hash/spaceAuth links (#63)
* add subspaces to be listed with edit_hash/spaceAuth authorization

* remove dead code from api_helpers.js

* add edit_hash authorization for requested space thumbnails

* handle /s/:hash links in frontend router

* set space_auth via a function, allow passing it to load_space

* rename variable in /s/:hash router in backend

* hide search, profile, breadcrumb in folders if not logged in, construct links to subspaces differently for anonymous editors
2020-06-02 20:47:58 +02:00

34 lines
962 B
JavaScript

'use strict';
require('../models/db');
var config = require('config');
const redis = require('../helpers/redis');
module.exports = (req, res, next) => {
res.header("Cache-Control", "no-cache");
req['channelId'] = req.headers['x-spacedeck-channel'];
req['spacePassword'] = req.headers['x-spacedeck-spacepassword'];
req['spaceAuth'] = req.query['spaceAuth'] || req.headers['x-spacedeck-space-auth'];
res['distributeCreate'] = function(model, object) {
if (!object) return;
redis.sendMessage("create", model, object, req.channelId);
this.status(201).json(object);
};
res['distributeUpdate'] = function(model, object) {
if (!object) return;
redis.sendMessage("update", model, object, req.channelId);
this.status(200).json(object);
};
res['distributeDelete'] = function(model, object) {
if (!object) return;
redis.sendMessage("delete", model, object, req.channelId);
this.sendStatus(204);
};
next();
}