aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(static)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-07-07 22:34:27 -0700
committerAdam Soltys <[email protected]>2025-07-07 22:34:27 -0700
commit209b1e64f1c4dda16a50e57c6570a3a35953085d (patch)
tree4e8b260e5b8f832b03dd41f17f65b42aba58f268 /src/routes/(static)
parent1b1718a4b64275bac8e1fe519d33c67e3a95f2c5 (diff)
downloadcoinos-ui-209b1e64f1c4dda16a50e57c6570a3a35953085d.tar.gz
coinos-ui-209b1e64f1c4dda16a50e57c6570a3a35953085d.zip
fund sweep
Diffstat (limited to 'src/routes/(static)')
-rw-r--r--src/routes/(static)/register/+page.server.ts38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/routes/(static)/register/+page.server.ts b/src/routes/(static)/register/+page.server.ts
index 2c2807bd..8c6d6a8d 100644
--- a/src/routes/(static)/register/+page.server.ts
+++ b/src/routes/(static)/register/+page.server.ts
@@ -1,5 +1,5 @@
-import { fd, get, login, post } from "$lib/utils";
-import { fail, redirect } from "@sveltejs/kit";
+import { fd, get, register } from "$lib/utils";
+import { redirect } from "@sveltejs/kit";
export const load = async ({ parent }) => {
const { user } = await parent();
@@ -14,39 +14,13 @@ export const load = async ({ parent }) => {
export const actions = {
default: async ({ cookies, request }) => {
const ip = request.headers.get("cf-connecting-ip");
-
const form = await fd(request);
- let { picture, username, password, pubkey, loginRedirect } = form;
- const user = { picture, username, password, pubkey };
- let error;
-
+ const { picture, username, password } = form;
+ let { loginRedirect } = form;
if (loginRedirect === "undefined") loginRedirect = undefined;
- let sk;
- try {
- ({ sk } = await post("/register", { user }, { "cf-connecting-ip": ip }));
- } catch (e) {
- ({ message: error } = e as Error);
- }
-
- try {
- await login(user, cookies, ip);
- error = null;
- } catch (e) {
- const { message } = e as Error;
- error ||= message;
- }
-
- const expires = new Date();
- expires.setSeconds(expires.getSeconds() + 21000000);
- cookies.set("sk", sk, {
- path: "/",
- expires,
- httpOnly: false,
- sameSite: "lax",
- });
-
- if (error) return fail(400, { error });
+ const user = { picture, username, password };
+ await register(user, ip, cookies, loginRedirect);
redirect(303, loginRedirect || `/${user.username}`);
},
};