mirror of
https://github.com/docmost/docmost.git
synced 2025-11-14 20:11:10 +10:00
add cookie duration
This commit is contained in:
@ -1,14 +1,17 @@
|
||||
import Cookies from "js-cookie";
|
||||
import { createJSONStorage, atomWithStorage } from "jotai/utils";
|
||||
import { ITokens } from '../types/auth.types';
|
||||
|
||||
import { ITokens } from "../types/auth.types";
|
||||
|
||||
const cookieStorage = createJSONStorage<ITokens>(() => {
|
||||
return {
|
||||
getItem: () => Cookies.get("authTokens"),
|
||||
setItem: (key, value) => Cookies.set(key, value),
|
||||
setItem: (key, value) => Cookies.set(key, value, { expires: 30 }),
|
||||
removeItem: (key) => Cookies.remove(key),
|
||||
};
|
||||
});
|
||||
|
||||
export const authTokensAtom = atomWithStorage<ITokens | null>("authTokens", null, cookieStorage);
|
||||
export const authTokensAtom = atomWithStorage<ITokens | null>(
|
||||
"authTokens",
|
||||
null,
|
||||
cookieStorage,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user