Fixing an issue with attempting to access a locked app causes a redirect loop locking up browser.
This commit is contained in:
parent
ed60a1fb1a
commit
453556d273
|
@ -67,6 +67,14 @@ export const getFrontendStore = () => {
|
||||||
initialise: async pkg => {
|
initialise: async pkg => {
|
||||||
const { layouts, screens, application, clientLibPath } = pkg
|
const { layouts, screens, application, clientLibPath } = pkg
|
||||||
const components = await fetchComponentLibDefinitions(application.appId)
|
const components = await fetchComponentLibDefinitions(application.appId)
|
||||||
|
// make sure app isn't locked
|
||||||
|
if (
|
||||||
|
components &&
|
||||||
|
components.status === 400 &&
|
||||||
|
components.message?.includes("lock")
|
||||||
|
) {
|
||||||
|
throw { ok: false, reason: "locked" }
|
||||||
|
}
|
||||||
store.update(state => ({
|
store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
libraries: application.componentLibraries,
|
libraries: application.componentLibraries,
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
import ICONS from "./icons"
|
import ICONS from "./icons"
|
||||||
|
|
||||||
let openDataSources = []
|
let openDataSources = []
|
||||||
$: enrichedDataSources = $datasources.list.map(datasource => {
|
$: enrichedDataSources = Array.isArray($datasources.list)
|
||||||
|
? $datasources.list.map(datasource => {
|
||||||
const selected = $datasources.selected === datasource._id
|
const selected = $datasources.selected === datasource._id
|
||||||
const open = openDataSources.includes(datasource._id)
|
const open = openDataSources.includes(datasource._id)
|
||||||
const containsSelected = containsActiveEntity(datasource)
|
const containsSelected = containsActiveEntity(datasource)
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
open: selected || open || containsSelected,
|
open: selected || open || containsSelected,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
: []
|
||||||
$: openDataSource = enrichedDataSources.find(x => x.open)
|
$: openDataSource = enrichedDataSources.find(x => x.open)
|
||||||
$: {
|
$: {
|
||||||
// Ensure the open data source is always included in the list of open
|
// Ensure the open data source is always included in the list of open
|
||||||
|
|
|
@ -11,12 +11,14 @@
|
||||||
function prepareData() {
|
function prepareData() {
|
||||||
let datasource = {}
|
let datasource = {}
|
||||||
let existingTypeCount = $datasources.list.filter(
|
let existingTypeCount = $datasources.list.filter(
|
||||||
ds => ds.source == integration.type
|
ds => ds.source === integration.type
|
||||||
).length
|
).length
|
||||||
|
|
||||||
let baseName = IntegrationNames[integration.type]
|
let baseName = IntegrationNames[integration.type]
|
||||||
let name =
|
let name =
|
||||||
existingTypeCount == 0 ? baseName : `${baseName}-${existingTypeCount + 1}`
|
existingTypeCount === 0
|
||||||
|
? baseName
|
||||||
|
: `${baseName}-${existingTypeCount + 1}`
|
||||||
|
|
||||||
datasource.type = "datasource"
|
datasource.type = "datasource"
|
||||||
datasource.source = integration.type
|
datasource.source = integration.type
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import NPSFeedbackForm from "components/feedback/NPSFeedbackForm.svelte"
|
import NPSFeedbackForm from "components/feedback/NPSFeedbackForm.svelte"
|
||||||
import { get } from "builderStore/api"
|
import { get } from "builderStore/api"
|
||||||
import { auth, admin } from "stores/portal"
|
import { auth, admin } from "stores/portal"
|
||||||
import { isActive, goto, layout } from "@roxi/routify"
|
import { isActive, goto, layout, redirect } from "@roxi/routify"
|
||||||
import Logo from "assets/bb-emblem.svg"
|
import Logo from "assets/bb-emblem.svg"
|
||||||
import { capitalise } from "helpers"
|
import { capitalise } from "helpers"
|
||||||
import UpgradeModal from "../../../../components/upgrade/UpgradeModal.svelte"
|
import UpgradeModal from "../../../../components/upgrade/UpgradeModal.svelte"
|
||||||
|
@ -34,7 +34,16 @@
|
||||||
const pkg = await res.json()
|
const pkg = await res.json()
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
try {
|
||||||
await store.actions.initialise(pkg)
|
await store.actions.initialise(pkg)
|
||||||
|
// edge case, lock wasn't known to client when it re-directed, or user went directly
|
||||||
|
} catch (err) {
|
||||||
|
if (!err.ok && err.reason === "locked") {
|
||||||
|
$redirect("../../")
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
await automationStore.actions.fetch()
|
await automationStore.actions.fetch()
|
||||||
await roles.fetch()
|
await roles.fetch()
|
||||||
return pkg
|
return pkg
|
||||||
|
|
|
@ -33,7 +33,7 @@ async function checkDevAppLocks(ctx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!(await doesUserHaveLock(appId, ctx.user))) {
|
if (!(await doesUserHaveLock(appId, ctx.user))) {
|
||||||
ctx.throw(403, "User does not hold app lock.")
|
ctx.throw(400, "User does not hold app lock.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// they do have lock, update it
|
// they do have lock, update it
|
||||||
|
|
Loading…
Reference in New Issue