* multi user wip * WIP MUM features * invitation mgmt * suspend or unsuspend users * workspace mangement * manage chats * manage chats * add Support for admin system settings for users to delete workspaces and limit chats per user * fix issue ith system var update app to lazy load invite page * cleanup and bug fixes * wrong method * update readme * update readme * update readme * bump version to 0.1.0
20 lines
623 B
JavaScript
20 lines
623 B
JavaScript
import { AUTH_TOKEN, AUTH_USER } from "./constants";
|
|
|
|
// Sets up the base headers for all authenticated requests so that we are able to prevent
|
|
// basic spoofing since a valid token is required and that cannot be spoofed
|
|
export function userFromStorage() {
|
|
try {
|
|
const userString = window.localStorage.getItem(AUTH_USER);
|
|
if (!userString) return null;
|
|
return JSON.parse(userString);
|
|
} catch {}
|
|
return {};
|
|
}
|
|
|
|
export function baseHeaders(providedToken = null) {
|
|
const token = providedToken || window.localStorage.getItem(AUTH_TOKEN);
|
|
return {
|
|
Authorization: token ? `Bearer ${token}` : null,
|
|
};
|
|
}
|