diff options
| author | Adam Soltys <[email protected]> | 2022-07-28 21:22:25 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-07-28 21:22:50 -0700 |
| commit | 49e7185efd45add123e0dbfcab077772b5ff22f6 (patch) | |
| tree | b154c499b6c81c3cef0fa42d4c9f44c1f3444034 /src/hooks | |
| parent | bcb252eb0b52f64449dad295595fdaa5e80cb5dc (diff) | |
| download | coinos-ui-49e7185efd45add123e0dbfcab077772b5ff22f6.tar.gz coinos-ui-49e7185efd45add123e0dbfcab077772b5ff22f6.zip | |
save token in cookie
Diffstat (limited to 'src/hooks')
| -rw-r--r-- | src/hooks/index.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/hooks/index.js b/src/hooks/index.js new file mode 100644 index 00000000..21e56052 --- /dev/null +++ b/src/hooks/index.js @@ -0,0 +1,16 @@ +import cookie from "cookie"; +export async function handle({ event, resolve }) { + let { request: { headers }, + } = event; + + const cookies = cookie.parse(headers.get("cookie") || ""); + let { token } = cookies; + event.locals = { token }; + + return resolve(event); +} + + +export const getSession = ({ locals: { token } }) => { + return { token }; +}; |
