mirror of
https://github.com/docmost/docmost.git
synced 2026-05-17 23:14:07 +08:00
990612793f
* Switch to httpOnly cookie * create endpoint to retrieve temporary collaboration token * cleanups
17 lines
440 B
TypeScript
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,
|
|
);
|