#11 make it possible to sign up
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 31s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 31s
This commit is contained in:
@@ -38,7 +38,8 @@
|
|||||||
<p>{user?.email}</p>
|
<p>{user?.email}</p>
|
||||||
<button class="btn" on:click={async () => signOut()}>Logout</button>
|
<button class="btn" on:click={async () => signOut()}>Logout</button>
|
||||||
{:else}
|
{:else}
|
||||||
<a href="/login" class="btn">Login</a>
|
<a href="/signup" class="btn">Sign Up</a>
|
||||||
|
<a href="/signin" class="btn">Sign In</a>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
auth = (await authImp).auth;
|
auth = (await authImp).auth;
|
||||||
await auth.authStateReady();
|
await auth.authStateReady();
|
||||||
if (!auth?.currentUser) {
|
if (!auth?.currentUser) {
|
||||||
goto('/login');
|
goto('/signin');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
class="max-w-xl mx-auto flex flex-col gap-4 h-full justify-center"
|
class="max-w-xl mx-auto flex flex-col gap-4 h-full justify-center"
|
||||||
on:submit|preventDefault={signIn}
|
on:submit|preventDefault={signIn}
|
||||||
>
|
>
|
||||||
<h2 class="text-6xl mb-10">Login</h2>
|
<h2 class="text-6xl mb-10">Sign In</h2>
|
||||||
<label class="input input-bordered flex items-center gap-2">
|
<label class="input input-bordered flex items-center gap-2">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -60,7 +60,11 @@
|
|||||||
<input type="password" class="grow" placeholder="Password" name="password" />
|
<input type="password" class="grow" placeholder="Password" name="password" />
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<button class="btn btn-primary self-end">Login</button>
|
<div class="flex justify-end items-center gap-5">
|
||||||
|
<p class="text-gray-500">Don't have an account?</p>
|
||||||
|
<a href="/signup" class="link gray-500">Sign Up</a>
|
||||||
|
<button class="btn btn-primary self-end">Sign In</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if errorStr}
|
{#if errorStr}
|
||||||
<p class="text-red-500">{errorStr}</p>
|
<p class="text-red-500">{errorStr}</p>
|
||||||
72
view/src/routes/signup/+page.svelte
Normal file
72
view/src/routes/signup/+page.svelte
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { createUserWithEmailAndPassword } from 'firebase/auth';
|
||||||
|
|
||||||
|
var errorStr: string | null = null;
|
||||||
|
|
||||||
|
const signUp = async (event: SubmitEvent) => {
|
||||||
|
errorStr = null;
|
||||||
|
const { auth } = await import('$lib/firebase');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = new FormData(event.target as HTMLFormElement);
|
||||||
|
await createUserWithEmailAndPassword(
|
||||||
|
auth,
|
||||||
|
data.get('email') as string,
|
||||||
|
data.get('password') as string
|
||||||
|
);
|
||||||
|
|
||||||
|
goto('/');
|
||||||
|
} catch (error: any) {
|
||||||
|
errorStr = error.code ? error.code : error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="max-w-xl mx-auto flex flex-col gap-4 h-full justify-center"
|
||||||
|
on:submit|preventDefault={signUp}
|
||||||
|
>
|
||||||
|
<h2 class="text-6xl mb-10">Sign Up</h2>
|
||||||
|
<label class="input input-bordered flex items-center gap-2">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="h-4 w-4 opacity-70"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M2.5 3A1.5 1.5 0 0 0 1 4.5v.793c.026.009.051.02.076.032L7.674 8.51c.206.1.446.1.652 0l6.598-3.185A.755.755 0 0 1 15 5.293V4.5A1.5 1.5 0 0 0 13.5 3h-11Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M15 6.954 8.978 9.86a2.25 2.25 0 0 1-1.956 0L1 6.954V11.5A1.5 1.5 0 0 0 2.5 13h11a1.5 1.5 0 0 0 1.5-1.5V6.954Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<input type="text" class="grow" placeholder="Email" name="email" />
|
||||||
|
</label>
|
||||||
|
<label class="input input-bordered flex items-center gap-2">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="h-4 w-4 opacity-70"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M14 6a4 4 0 0 1-4.899 3.899l-1.955 1.955a.5.5 0 0 1-.353.146H5v1.5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-2.293a.5.5 0 0 1 .146-.353l3.955-3.955A4 4 0 1 1 14 6Zm-4-2a.75.75 0 0 0 0 1.5.5.5 0 0 1 .5.5.75.75 0 0 0 1.5 0 2 2 0 0 0-2-2Z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<input type="password" class="grow" placeholder="Password" name="password" />
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="flex justify-end items-center gap-5">
|
||||||
|
<p class="text-gray-500">Already have an account?</p>
|
||||||
|
<a href="/signin" class="link gray-500">Sign In</a>
|
||||||
|
<button class="btn btn-primary self-end">Sign Up</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if errorStr}
|
||||||
|
<p class="text-red-500">{errorStr}</p>
|
||||||
|
{/if}
|
||||||
|
</form>
|
||||||
Reference in New Issue
Block a user