diff options
| author | Adam Soltys <[email protected]> | 2025-01-02 12:09:40 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-01-02 12:09:40 -0800 |
| commit | 1bfdc18184fd57b741f5ebdfb0e323747f4d06b0 (patch) | |
| tree | 6518ad4b5a249bc79e7023b9253710f775bdbb5b | |
| parent | 1837d90cc8ef3b79bded1ca47a49e68b082b45ef (diff) | |
| download | coinos-ui-1bfdc18184fd57b741f5ebdfb0e323747f4d06b0.tar.gz coinos-ui-1bfdc18184fd57b741f5ebdfb0e323747f4d06b0.zip | |
profile to picture
| -rw-r--r-- | src/routes/(static)/register/+page.server.ts | 4 | ||||
| -rw-r--r-- | src/routes/(static)/register/+page.svelte | 22 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/routes/(static)/register/+page.server.ts b/src/routes/(static)/register/+page.server.ts index b459c622..561b34a0 100644 --- a/src/routes/(static)/register/+page.server.ts +++ b/src/routes/(static)/register/+page.server.ts @@ -16,9 +16,9 @@ export const actions = { const ip = request.headers.get("cf-connecting-ip"); const form = await fd(request); - let { profile, username, password, cipher, salt, pubkey, loginRedirect } = + let { picture, username, password, cipher, salt, pubkey, loginRedirect } = form; - const user = { profile, username, password, cipher, salt, pubkey }; + const user = { picture, username, password, cipher, salt, pubkey }; let error; if (loginRedirect === "undefined") loginRedirect = undefined; diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte index 8738e32b..69c6a588 100644 --- a/src/routes/(static)/register/+page.svelte +++ b/src/routes/(static)/register/+page.svelte @@ -25,7 +25,7 @@ animals, } from "unique-names-generator"; - let { form = $bindable(), data } = $props(); + let { form, data } = $props(); let nostr = $state(); let { id } = $derived(data); @@ -97,22 +97,23 @@ data.set(k, user[k]); } - data.set("profile", punks[index]); + data.set("picture", punks[index]); if ($avatar) { try { let { hash } = JSON.parse( await upload($avatar.file, $avatar.type, $avatar.progress, token), ); - data.set("profile", hash); - await fetch(`/api/public/${hash}.webp`, { + let url = `${$page.url.origin}/api/public/${hash}.webp`; + data.set("picture", url); + await fetch(url, { cache: "reload", mode: "no-cors", }); } catch (e) { console.log("problem uploading avatar", e); } - } + } const response = await fetch("/register", { method: "POST", @@ -136,7 +137,7 @@ let progress; let handleFile = async ({ target }) => { - let type = "profile"; + let type = "picture"; let file = target.files[0]; if (!file) return; @@ -212,7 +213,7 @@ type="file" class="hidden" bind:this={avatarInput} - onchange={(e) => handleFile(e, "profile")} + onchange={(e) => handleFile(e, "picture")} /> <div class="relative"> @@ -298,7 +299,12 @@ bind:show={revealPassword} /> - <button type="submit" class="btn btn-accent" disabled={loading} bind:this={btn}> + <button + type="submit" + class="btn btn-accent" + disabled={loading} + bind:this={btn} + > {#if loading} <Spinner /> {:else} |
