client - should recognise new cookie format
This commit is contained in:
parent
11e56467b8
commit
849fcfe819
|
@ -2,8 +2,10 @@ export const getAppId = cookie => {
|
|||
const base64Token = cookie
|
||||
.split(";")
|
||||
.find(c => c.trim().startsWith("budibase:token"))
|
||||
.split("=")[1]
|
||||
.substring(lengthOfKey)
|
||||
|
||||
const user = JSON.parse(atob(base64Token.split(".")[1]))
|
||||
return user.appId
|
||||
}
|
||||
|
||||
const lengthOfKey = "budibase:token=".length
|
||||
|
|
|
@ -18,7 +18,7 @@ describe("screenRouting", () => {
|
|||
|
||||
it("should load correct screen, for initial URL, when appRootPath is something", async () => {
|
||||
const { page, screens } = pageWith3Screens()
|
||||
const { dom } = await load(page, screens, "/TEST_APP_ID/screen2", "localhost")
|
||||
const { dom } = await load(page, screens, "/TEST_APP_ID/screen2", "127.0.0.1")
|
||||
|
||||
const rootDiv = dom.window.document.body.children[0]
|
||||
expect(rootDiv.children.length).toBe(1)
|
||||
|
@ -50,8 +50,8 @@ describe("screenRouting", () => {
|
|||
const { dom, app } = await load(
|
||||
page,
|
||||
screens,
|
||||
"/testApp/screen2",
|
||||
"/testApp"
|
||||
"/TEST_APP_ID/screen2",
|
||||
"127.0.0.1"
|
||||
)
|
||||
|
||||
app.routeTo()("/screen3")
|
||||
|
|
|
@ -7,7 +7,7 @@ export const load = async (page, screens, url, host = "test.com") => {
|
|||
|
||||
const fullUrl = `http://${host}${url}`
|
||||
const cookieJar = new jsdom.CookieJar()
|
||||
const cookie = btoa('{}{"appId":"TEST_APP_ID"}signature')
|
||||
const cookie = `${btoa("{}")}.${btoa('{"appId":"TEST_APP_ID"}')}.signature`
|
||||
cookieJar.setCookie(
|
||||
`budibase:token=${cookie};domain=${host};path=/`,
|
||||
fullUrl,
|
||||
|
|
Loading…
Reference in New Issue