overleaf/services/web/app/coffee/Features/Templates/TemplatesMiddlewear.coffee

26 lines
697 B
CoffeeScript
Raw Normal View History

settings = require("settings-sharelatex")
logger = require("logger-sharelatex")
2014-02-12 10:23:40 +00:00
module.exports =
saveTemplateDataInSession: (req, res, next)->
if req.query.templateName
req.session.templateData = req.query
next()
id_or_tag_parse: (req, res, next)->
tag_or_template_id = req.params.tag_or_template_id
if _isObjectId(tag_or_template_id)
req.params.template_id = tag_or_template_id
else
req.params.tag_name = tag_or_template_id
next()
_isObjectId: _isObjectId = (tag_or_id)->
checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$")
checkForHexRegExp.test(tag_or_id)
2014-02-12 10:23:40 +00:00
insert_templates_user_id: (req, res, next)->
2014-08-20 13:47:27 +00:00
req.params.user_id = settings.templates.user_id
next()