budibase/packages/client/src/render/getAppId.js

12 lines
291 B
JavaScript
Raw Normal View History

2020-06-18 17:59:31 +02:00
export const getAppId = cookie => {
const base64Token = cookie
.split(";")
2020-06-18 17:59:31 +02:00
.find(c => c.trim().startsWith("budibase:token"))
.substring(lengthOfKey)
2020-06-18 17:59:31 +02:00
const user = JSON.parse(atob(base64Token.split(".")[1]))
return user.appId
}
const lengthOfKey = "budibase:token=".length