Some further work, logout and preview appear to be working much better now.

This commit is contained in:
Michael Drury 2020-11-02 22:46:31 +00:00
parent a1fd261af6
commit 871e9b123e
6 changed files with 16 additions and 10 deletions

View File

@ -1,3 +1,3 @@
Cypress.Cookies.defaults({
preserve: "builder:token",
preserve: "budibase:builder:local",
})

View File

@ -84,7 +84,8 @@
<Button
secondary
on:click={() => {
document.cookie = 'budibase:token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
// reset cookies for this app
document.cookie = `budibase:${application}:local=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
window.open(`/${application}`)
}}>
Preview

View File

@ -9,7 +9,7 @@ export const load = async (page, screens, url, host = "test.com") => {
const cookieJar = new jsdom.CookieJar()
const cookie = `${btoa("{}")}.${btoa('{"appId":"TEST_APP_ID"}')}.signature`
cookieJar.setCookie(
`budibase:local:TEST_APP_ID=${cookie};domain=${host};path=/`,
`budibase:TEST_APP_ID:local=${cookie};domain=${host};path=/`,
fullUrl,
{
looseMode: false,

View File

@ -34,7 +34,7 @@ exports.defaultHeaders = appId => {
return {
Accept: "application/json",
Cookie: [`builder:token=${builderToken}`],
Cookie: [`budibase:builder=${builderToken}:local`],
}
}
@ -209,7 +209,7 @@ const createUserWithPermissions = async (
const loginResult = await request
.post(`/api/authenticate`)
.set({ Cookie: `budibase:${appId}=${anonToken}` })
.set({ Cookie: `budibase:${appId}:local=${anonToken}` })
.send({ username, password })
// returning necessary request headers

View File

@ -37,6 +37,6 @@ exports.getAppId = ctx => {
* @returns {string} The name of the token trying to find
*/
exports.getCookieName = (appId = null) => {
let mid = env.CLOUD ? "cloud" : "local"
return `budibase:${mid}:${appId ? appId : "builder"}`
let environment = env.CLOUD ? "cloud" : "local"
return `budibase:${appId ? appId : "builder"}:${environment}`
}

View File

@ -18,9 +18,14 @@
}
const logOut = () => {
document.cookie =
"budibase:token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"
location.reload()
// TODO: not the best way to clear cookie, try to find better way
const appId = location.pathname.split("/")[1]
if (appId) {
for (let environment of ["local", "cloud"]) {
document.cookie = `budibase:${appId}:${environment}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
}
}
location.href=`/${appId}`
}
</script>