Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Replace literal with constant

dominik-zeglen339f37693839
diff --git a/saleor/static/dashboard-next/auth/index.tsx b/saleor/static/dashboard-next/auth/index.tsx
index 556d05a352..64676a39b5 100644
--- a/saleor/static/dashboard-next/auth/index.tsx
+++ b/saleor/static/dashboard-next/auth/index.tsx
@@ -3,6 +3,8 @@ import * as React from "react";
import { User } from "./types/User";
import Login from "./views/Login";
+const TOKEN_STORAGE_KEY = "dashboardAuth";
+
interface UserContext {
login: (username: string, password: string, persist: boolean) => void;
logout: () => void;
@@ -15,17 +17,17 @@ export const UserContext = React.createContext<UserContext>({
});
export const getAuthToken = () =>
- localStorage.getItem("dashboardAuth") ||
- sessionStorage.getItem("dashboardAuth");
+ localStorage.getItem(TOKEN_STORAGE_KEY) ||
+ sessionStorage.getItem(TOKEN_STORAGE_KEY);
export const setAuthToken = (token: string, persist: boolean) =>
persist
- ? localStorage.setItem("dashboardAuth", token)
- : sessionStorage.setItem("dashboardAuth", token);
+ ? localStorage.setItem(TOKEN_STORAGE_KEY, token)
+ : sessionStorage.setItem(TOKEN_STORAGE_KEY, token);
export const removeAuthToken = () => {
- localStorage.removeItem("dashboardAuth");
- sessionStorage.removeItem("dashboardAuth");
+ localStorage.removeItem(TOKEN_STORAGE_KEY);
+ sessionStorage.removeItem(TOKEN_STORAGE_KEY);
};
export default Login;