From f6cfef899e3f671826f843b8d103aef2375a6521 Mon Sep 17 00:00:00 2001 From: mntmn <lukas@mntmn.com> Date: Mon, 11 May 2020 18:25:44 +0200 Subject: [PATCH] allow looking up spaces via slug --- middlewares/space_helpers.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/middlewares/space_helpers.js b/middlewares/space_helpers.js index 6459529..5f137cb 100644 --- a/middlewares/space_helpers.js +++ b/middlewares/space_helpers.js @@ -1,6 +1,7 @@ 'use strict'; const db = require('../models/db'); +const { Op } = require("sequelize"); var config = require('config'); module.exports = (req, res, next) => { @@ -53,8 +54,12 @@ module.exports = (req, res, next) => { 'email': 1 }; + // find space by id or slug db.Space.findOne({where: { - "_id": spaceId + [Op.or]: [ + {"_id": spaceId}, + {"edit_slug": spaceId} + ] }}).then(function(space) { if (space) { -- GitLab