* WIP custom footer icons * UI for updating footer icons complete and backend to save/modify * add backend for unprotected footer fetch * break out footer into separate component and render footer items using a cache for 1 hour * wip review * refactor & cleanup * Optimize footer form component Optimize caching for footer icons Add validation on SystemSetting upserts Normalize fallback items for footer_data * Adjust max icons to 3 * fix success message on remove * fix success message on remove --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
27 lines
762 B
JavaScript
27 lines
762 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,
|
|
};
|
|
}
|
|
|
|
export function safeJsonParse(jsonString, fallback = null) {
|
|
try {
|
|
return JSON.parse(jsonString);
|
|
} catch {}
|
|
return fallback;
|
|
}
|