aboutsummaryrefslogtreecommitdiffstats
path: root/src/hooks
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-07-28 21:22:25 -0700
committerAdam Soltys <[email protected]>2022-07-28 21:22:50 -0700
commit81a073638e03f57abd9016ce246940e602e8366d (patch)
treeb4dffb2a5e4e23f7ee9b1fd5cb5804f9b741590c /src/hooks
parent0dfe39f9039bebd123369f0d8e7b7f80a6807c9f (diff)
downloadcoinos-ui-81a073638e03f57abd9016ce246940e602e8366d.tar.gz
coinos-ui-81a073638e03f57abd9016ce246940e602e8366d.zip
save token in cookie
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/index.js16
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 };
+};