Files
docmost/apps/client/src/features/auth/atoms/auth-tokens-atom.ts
T
Philip Okugbe 990612793f refactor: switch to HttpOnly cookie (#660)
* Switch to httpOnly cookie
* create endpoint to retrieve temporary collaboration token

* cleanups
2025-01-22 22:11:11 +00:00

17 lines
440 B
TypeScript

import Cookies from "js-cookie";
import { createJSONStorage, atomWithStorage } from "jotai/utils";
const cookieStorage = createJSONStorage<any>(() => {
return {
getItem: () => Cookies.get("authTokens"),
setItem: (key, value) => Cookies.set(key, value, { expires: 30 }),
removeItem: (key) => Cookies.remove(key),
};
});
export const authTokensAtom = atomWithStorage<any | null>(
"authTokens",
null,
cookieStorage,
);