Fixing an issue with portal calls causing the app to be re-locked.

This commit is contained in:
mike12345567 2021-05-13 15:32:03 +01:00
parent 95679106ac
commit e560390d8a
4 changed files with 8 additions and 5 deletions

View File

@ -32,6 +32,9 @@ exports.getRedisOptions = (clustered = false) => {
}
exports.addDbPrefix = (db, key) => {
if (key.includes(db)) {
return key
}
return `${db}${SEPARATOR}${key}`
}

View File

@ -2,7 +2,6 @@ const fetch = require("node-fetch")
const env = require("../../environment")
const { checkSlashesInUrl } = require("../../utilities")
const { request } = require("../../utilities/workerRequests")
const { getGlobalIDFromUserMetadataID } = require("../../db/utils")
const { clearLock } = require("../../utilities/redis")
async function redirect(ctx, method) {
@ -35,7 +34,7 @@ exports.redirectDelete = async ctx => {
await redirect(ctx, "DELETE")
}
exports.removeLock = async ctx => {
exports.clearLock = async ctx => {
const { appId } = ctx.params
try {
await clearLock(appId, ctx.user)

View File

@ -16,7 +16,7 @@ if (env.isDev() || env.isTest()) {
router.delete(
"/api/dev/:appId/lock",
authorized(BUILDER),
controller.removeLock
controller.clearLock
)
module.exports = router

View File

@ -41,9 +41,10 @@ module.exports = (permType, permLevel = null) => async (ctx, next) => {
}
const builderCall = permType === PermissionTypes.BUILDER
const referer = ctx.headers["referer"]
const editingApp = referer ? referer.includes(ctx.appId) : false
// this makes sure that builder calls abide by dev locks
if (builderCall) {
if (builderCall && editingApp) {
await checkDevAppLocks(ctx)
}