mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 12:41:11 +10:00
Implement frontend auth and user features - WIP
This commit is contained in:
14
frontend/src/features/auth/atoms/auth-tokens-atom.ts
Normal file
14
frontend/src/features/auth/atoms/auth-tokens-atom.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import Cookies from "js-cookie";
|
||||
import { createJSONStorage, atomWithStorage } from "jotai/utils";
|
||||
import { ITokens } from "@/features/auth/types/auth.types";
|
||||
|
||||
|
||||
const cookieStorage = createJSONStorage<ITokens>(() => {
|
||||
return {
|
||||
getItem: () => Cookies.get("authTokens"),
|
||||
setItem: (key, value) => Cookies.set(key, value),
|
||||
removeItem: (key) => Cookies.remove(key),
|
||||
};
|
||||
});
|
||||
|
||||
export const authTokensAtom = atomWithStorage<ITokens | null>("authTokens", null, cookieStorage);
|
||||
Reference in New Issue
Block a user