aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/login.js
diff options
context:
space:
mode:
authorAdrien Hopkins <[email protected]>2022-08-02 13:13:27 -0500
committerAdrien Hopkins <[email protected]>2022-08-02 13:13:27 -0500
commitc21ee41b206db79b2157d8743b0473a094448dfb (patch)
treefac1a595e451c0b32ceedfe4fb70855270456377 /src/routes/login.js
parent3b216dd6c170a7d71d21a391098c554008c8bdb4 (diff)
parent05f5001fc7d325e31d9c777be11343604c72fbfd (diff)
downloadcoinos-ui-c21ee41b206db79b2157d8743b0473a094448dfb.tar.gz
coinos-ui-c21ee41b206db79b2157d8743b0473a094448dfb.zip
Merge branch 'master' into i18n
Diffstat (limited to 'src/routes/login.js')
-rw-r--r--src/routes/login.js27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/routes/login.js b/src/routes/login.js
index e8c74365..db1fbb6c 100644
--- a/src/routes/login.js
+++ b/src/routes/login.js
@@ -1,13 +1,24 @@
-import got from 'got';
+import { post } from '$lib/utils';
+import cookie from 'cookie';
+
+let maxAge = 30 * 24 * 60 * 60;
export async function POST({ request }) {
- let json = await request.json();
+ let body = await post('/login', await request.json());
- let body = await got
- .post('http://localhost:3119/login', {
- json
- })
- .json();
+ let expires = new Date();
+ expires.setSeconds(expires.getSeconds() + maxAge);
- return { body };
+ return {
+ body,
+ headers: {
+ 'set-cookie': cookie.serialize('token', body.token, {
+ httpOnly: true,
+ maxAge,
+ sameSite: 'lax',
+ path: '/',
+ expires
+ })
+ }
+ };
}