aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-23 22:59:29 -0800
committerAdam Soltys <[email protected]>2023-11-23 23:00:14 -0800
commit537401d4f3e7d3a90f5ff7a55feb9c05d4ac9f5e (patch)
tree99cd95009958d1af8e62cc2e58ff22fe3d9d7880 /src
parentcb6f474608cd0b91c2cf3258f2b07f930bc6f8b7 (diff)
downloadcoinos-ui-537401d4f3e7d3a90f5ff7a55feb9c05d4ac9f5e.tar.gz
coinos-ui-537401d4f3e7d3a90f5ff7a55feb9c05d4ac9f5e.zip
don't prefill registration form
Diffstat (limited to 'src')
-rw-r--r--src/lib/store.js2
-rw-r--r--src/routes/(app)/register/+page.server.js21
-rw-r--r--src/routes/(app)/register/+page.svelte41
3 files changed, 32 insertions, 32 deletions
diff --git a/src/lib/store.js b/src/lib/store.js
index 64cf015e..3d8e687d 100644
--- a/src/lib/store.js
+++ b/src/lib/store.js
@@ -43,7 +43,7 @@ export const last = writable();
export const loginRedirect = writable();
export const decrypted = persistLocal('decrypted', {});
export const newPayment = persistLocal('newPayment');
-export const password = persistLocal('password');
+export const password = writable();
export const passwordPrompt = writable();
export const pin = writable();
export const rate = writable();
diff --git a/src/routes/(app)/register/+page.server.js b/src/routes/(app)/register/+page.server.js
index f2b49e3f..45344907 100644
--- a/src/routes/(app)/register/+page.server.js
+++ b/src/routes/(app)/register/+page.server.js
@@ -1,10 +1,3 @@
-import {
- NumberDictionary,
- uniqueNamesGenerator,
- colors,
- adjectives,
- animals
-} from 'unique-names-generator';
import { fail, redirect } from '@sveltejs/kit';
import { fd, post, login } from '$lib/utils';
@@ -12,21 +5,9 @@ export const load = async ({ parent }) => {
let { user } = await parent();
if (user) throw redirect(307, `/${user.username}`);
- let username = uniqueNamesGenerator({
- dictionaries: [animals, NumberDictionary.generate({ min: 10, max: 99 })],
- length: 2,
- separator: ''
- });
-
- let password = uniqueNamesGenerator({
- dictionaries: [colors, NumberDictionary.generate({ min: 100, max: 999 })],
- length: 2,
- separator: ''
- });
-
let index = Math.floor(Math.random() * 64) + 1;
- return { index, username, password };
+ return { index };
};
export const actions = {
diff --git a/src/routes/(app)/register/+page.svelte b/src/routes/(app)/register/+page.svelte
index 573de4d0..a9f9d047 100644
--- a/src/routes/(app)/register/+page.svelte
+++ b/src/routes/(app)/register/+page.svelte
@@ -12,11 +12,20 @@
import { t } from '$lib/translations';
import { page } from '$app/stores';
import { generate } from '$lib/nostr';
+ import {
+ NumberDictionary,
+ uniqueNamesGenerator,
+ colors,
+ adjectives,
+ animals
+ } from 'unique-names-generator';
export let form;
export let data;
$: data && ($avatar = undefined);
+ let username;
+ let { index } = data;
let cleared;
let clear = () => {
@@ -29,16 +38,20 @@
};
let refresh = async () => {
- await invalidateAll();
- await tick();
- username = data.username;
- $password = data.password;
- };
+ username = uniqueNamesGenerator({
+ dictionaries: [animals, NumberDictionary.generate({ min: 10, max: 99 })],
+ length: 2,
+ separator: ''
+ });
- let username = data.username;
- $password = data.password;
+ $password = uniqueNamesGenerator({
+ dictionaries: [colors, NumberDictionary.generate({ min: 100, max: 999 })],
+ length: 2,
+ separator: ''
+ });
- let { index } = data;
+ revealPassword = true;
+ };
afterNavigate(async () => {
try {
@@ -63,7 +76,7 @@
$: token && token?.length === 6 && tick().then(() => btn.click());
- let revealPassword = true;
+ let revealPassword;
let loading;
async function handleSubmit(e) {
@@ -192,6 +205,8 @@
<div class="relative">
<label for="username" class="font-semibold">{$t('login.username')}</label>
<input
+ use:focus
+ tabindex="1"
name="username"
type="text"
required
@@ -200,8 +215,8 @@
on:focus={clear}
autocapitalize="none"
/>
- <button type="button" on:click={refresh} class="absolute right-0 top-4">
- <Icon icon="refresh" style="w-6 m-6" />
+ <button type="button" on:click={refresh} class="absolute right-0 top-4" tabindex="5">
+ <Icon icon="random" style="w-10 m-4" />
</button>
</div>
@@ -209,6 +224,7 @@
<label for="password" class="block font-semibold">{$t('login.password')}</label>
{#if revealPassword}
<input
+ tabindex="2"
name="password"
type="text"
required
@@ -218,6 +234,7 @@
/>
{:else}
<input
+ tabindex="2"
name="password"
type="password"
required
@@ -229,6 +246,7 @@
{/if}
<button
type="button"
+ tabindex="4"
on:click={() => (revealPassword = !revealPassword)}
class="absolute right-0 top-4"
>
@@ -241,6 +259,7 @@
</p>
<button
+ tabindex="3"
type="submit"
class="bg-black text-white w-full rounded-2xl p-4 font-semibold hover:opacity-80"
disabled={loading}