2020-07-03 00:22:20 +02:00
|
|
|
export const parseAppIdFromCookie = docCookie => {
|
2020-06-19 17:59:46 +02:00
|
|
|
const cookie =
|
|
|
|
docCookie.split(";").find(c => c.trim().startsWith("budibase:token")) ||
|
|
|
|
docCookie.split(";").find(c => c.trim().startsWith("builder:token"))
|
|
|
|
|
2020-10-15 15:26:33 +02:00
|
|
|
if (!cookie) return location.pathname.replace("/")
|
|
|
|
|
2020-06-19 17:59:46 +02:00
|
|
|
const base64Token = cookie.substring(lengthOfKey)
|
2020-06-18 17:59:31 +02:00
|
|
|
|
|
|
|
const user = JSON.parse(atob(base64Token.split(".")[1]))
|
|
|
|
return user.appId
|
|
|
|
}
|
2020-06-19 08:04:55 +02:00
|
|
|
|
|
|
|
const lengthOfKey = "budibase:token=".length
|