diff options
| author | Adam Soltys <[email protected]> | 2026-02-06 17:22:01 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-06 17:22:01 +0000 |
| commit | 8ec5dda44f4676a2e5dae609792710b0719cec43 (patch) | |
| tree | b018ac129dce268ffd0f355f379c1be0f693a1e9 /src/routes | |
| parent | c9a73999ba678955a3017c4d8442ec4e0b60a0d1 (diff) | |
| download | coinos-ui-8ec5dda44f4676a2e5dae609792710b0719cec43.tar.gz coinos-ui-8ec5dda44f4676a2e5dae609792710b0719cec43.zip | |
fix tor login
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(static)/login/+page.server.ts | 9 | ||||
| -rw-r--r-- | src/routes/(static)/register/+page.server.ts | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/routes/(static)/login/+page.server.ts b/src/routes/(static)/login/+page.server.ts index d81f2ccb..6c82a209 100644 --- a/src/routes/(static)/login/+page.server.ts +++ b/src/routes/(static)/login/+page.server.ts @@ -25,7 +25,7 @@ export const actions = { if (loginRedirect === "undefined") loginRedirect = undefined; try { - await login(user, cookies, request.headers.get("cf-connecting-ip")); + await login(user, cookies, request.headers.get("cf-connecting-ip"), request.headers.get("host")); } catch (e) { const { message } = e as Error; return fail(400, { error: "Login failed", message, ...form }); @@ -49,15 +49,18 @@ export const actions = { "content-type": "application/json", accept: "application/json", "cf-connecting-ip": request.headers.get("cf-connecting-ip"), + host: request.headers.get("host"), }, }); + const text = await res.text(); + if (res.status === 401) { - const text = await res.text(); if (text.startsWith("2fa")) throw new Error("2fa"); + throw new Error(text); } - const { user, token } = await res.json(); + const { user, token } = JSON.parse(text); if (!token) throw new Error("Login failed"); const { username, language } = user; diff --git a/src/routes/(static)/register/+page.server.ts b/src/routes/(static)/register/+page.server.ts index d2dbe299..2bcf6f2d 100644 --- a/src/routes/(static)/register/+page.server.ts +++ b/src/routes/(static)/register/+page.server.ts @@ -14,12 +14,13 @@ export const load = async ({ parent }) => { export const actions = { default: async ({ cookies, request }) => { const ip = request.headers.get("cf-connecting-ip"); + const host = request.headers.get("host"); const form = await fd(request); const { picture, username, password, challenge, recaptcha } = form; let { loginRedirect } = form; if (loginRedirect === "undefined") loginRedirect = undefined; const user = { picture, username, password, challenge, recaptcha }; - return register(user, ip, cookies, loginRedirect); + return register(user, ip, cookies, loginRedirect, host); }, }; |
