aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-12-05 09:44:31 -0800
committerAdam Soltys <[email protected]>2023-12-05 09:44:31 -0800
commit62a813a07abde15de106446e9eff15009922bd11 (patch)
treeb80e1367789e47def9020ac3b6043ce1872b78b2 /src
parent5933fe57b91f4a60ce934417fa967f6b0fa65cc0 (diff)
downloadcoinos-ui-62a813a07abde15de106446e9eff15009922bd11.tar.gz
coinos-ui-62a813a07abde15de106446e9eff15009922bd11.zip
username cookie
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/[username]/+layout.server.js7
-rw-r--r--src/routes/start/+server.js6
2 files changed, 9 insertions, 4 deletions
diff --git a/src/routes/(app)/[username]/+layout.server.js b/src/routes/(app)/[username]/+layout.server.js
index 0e962173..3b25b3b5 100644
--- a/src/routes/(app)/[username]/+layout.server.js
+++ b/src/routes/(app)/[username]/+layout.server.js
@@ -1,11 +1,16 @@
import { get } from "$lib/utils";
import { error } from "@sveltejs/kit";
-export let load = async ({ depends, params: { username } }) => {
+export let load = async ({ cookies, depends, params: { username } }) => {
depends("app:user");
try {
let subject = await get(`/users/${username}`);
+
+ let expires = new Date();
+ expires.setSeconds(expires.getSeconds() + 380 * 24 * 60 * 60);
+ cookies.set("username", username, { path: "/", expires });
+
return { subject };
} catch (e) {
throw error(500, "Unable to retrieve user account data");
diff --git a/src/routes/start/+server.js b/src/routes/start/+server.js
index c351df70..e5d93497 100644
--- a/src/routes/start/+server.js
+++ b/src/routes/start/+server.js
@@ -2,9 +2,9 @@ import { auth, get } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export async function GET({ cookies }) {
- let user = cookies.get("user");
- if (user) {
- throw redirect(307, `/${user}/receive`);
+ let username = cookies.get("username");
+ if (username) {
+ throw redirect(307, `/${username}/receive`);
}
throw redirect(307, "/");