livebook/assets/js/lib/app.js
Jonatan Kłosko 4334e8a58e
Add access control to apps (#1715)
Co-authored-by: José Valim <jose.valim@dashbit.co>
2023-02-18 01:16:42 +01:00

22 lines
461 B
JavaScript

import { load, store } from "./storage";
const APP_AUTH_TOKEN_PREFIX = "app_auth_token:";
export function storeAppAuthToken(slug, token) {
store(APP_AUTH_TOKEN_PREFIX + slug, token);
}
export function loadAppAuthToken() {
const path = window.location.pathname;
if (path.startsWith("/apps/")) {
const slug = path.split("/")[2];
const token = load(APP_AUTH_TOKEN_PREFIX + slug);
if (token) {
return token;
}
}
return null;
}