initial commit
This commit is contained in:
@@ -16,6 +16,37 @@ import axios from 'axios';
|
||||
export const DOORMILE_TOKEN_KEY = 'doormileToken';
|
||||
export const DOORMILE_USER_KEY = 'doormileUser';
|
||||
|
||||
/**
|
||||
* The rest of the signed-in identity, written by Login.jsx because parts of the
|
||||
* data layer read it straight from storage rather than through context.
|
||||
*
|
||||
* Ending a session has to clear these too. They are not the credential, but
|
||||
* `tenantid` is what decides whether a login is Doormile staff or scoped to one
|
||||
* client — so a stale one left behind by the previous operator is both their
|
||||
* identity sitting readable in the browser and a value the next session could
|
||||
* read before signing in.
|
||||
*/
|
||||
export const DOORMILE_SESSION_KEYS = ['authname', 'firstname', 'userid', 'roleid', 'tenantid'];
|
||||
|
||||
/**
|
||||
* Doormile AI's saved thread and its archive (owned by AIPanel.jsx's
|
||||
* HISTORY_KEY / CONVERSATIONS_KEY).
|
||||
*
|
||||
* These are session data, not a preference: the bot answers about live orders,
|
||||
* so a thread routinely contains order numbers, customer names and phone
|
||||
* numbers. Production users are warehouse and dispatch staff, often on a shared
|
||||
* terminal — leaving the transcript behind hands the next operator the last
|
||||
* one's work. The panel width is a preference and stays.
|
||||
*/
|
||||
export const DOORMILE_ASSISTANT_KEYS = ['doormileBotHistory', 'doormileBotConversations'];
|
||||
|
||||
/** Clears every key that makes up a Doormile session. */
|
||||
export const clearStoredSession = () => {
|
||||
localStorage.removeItem(DOORMILE_TOKEN_KEY);
|
||||
localStorage.removeItem(DOORMILE_USER_KEY);
|
||||
[...DOORMILE_SESSION_KEYS, ...DOORMILE_ASSISTANT_KEYS].forEach((key) => localStorage.removeItem(key));
|
||||
};
|
||||
|
||||
/** The backend, for every `/admin/*` call the console makes. */
|
||||
export const DOORMILE_API_URL = 'https://api.doormile.com/api/v1';
|
||||
|
||||
@@ -51,8 +82,7 @@ doormileAxios.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (error.response?.status === 401 && !window.location.href.includes('/login')) {
|
||||
localStorage.removeItem(DOORMILE_TOKEN_KEY);
|
||||
localStorage.removeItem(DOORMILE_USER_KEY);
|
||||
clearStoredSession();
|
||||
window.location.replace('/login');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user