Init Project
This is a pretty far-developed starting point. Authentication has been intialized with Better-Auth, a database has been setup with Prisma, and Google + email logins have been enabled, as well as Google + Email registration.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
import { authClient } from '$lib/auth-client';
|
||||
import Window from '$lib/components/containers/Window.svelte';
|
||||
let email = $state('');
|
||||
let password = $state('');
|
||||
let error = $state('');
|
||||
let rememberMe = $state(false);
|
||||
|
||||
async function handleSubmit() {
|
||||
const { data, error: authError } = await authClient.signIn.email({
|
||||
email,
|
||||
password,
|
||||
rememberMe
|
||||
});
|
||||
|
||||
if (authError) {
|
||||
console.log(data);
|
||||
console.log(authError);
|
||||
error = authError.message as string;
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = '/';
|
||||
}
|
||||
</script>
|
||||
|
||||
<Window>
|
||||
<div>
|
||||
{#if error}
|
||||
<span class="text-red-600">{error}</span>
|
||||
{/if}
|
||||
<form
|
||||
onsubmit={handleSubmit}
|
||||
class="bg-grey-200 my-6 flex flex-col items-center justify-center"
|
||||
>
|
||||
<p>Login</p>
|
||||
<input type="email" placeholder="Email Address" bind:value={email} required class="my-2" />
|
||||
<input type="password" placeholder="Password" bind:value={password} required class="my-2" />
|
||||
<button class="mt-4 rounded bg-blue-200 px-4 py-2" type="submit">Sign In</button>
|
||||
</form>
|
||||
<div class="mt-4 flex flex-col items-center justify-center">
|
||||
<span>Or</span>
|
||||
<button
|
||||
onclick={async () => {
|
||||
authClient.signIn.social({ provider: 'google' });
|
||||
}}
|
||||
>
|
||||
<img src="light/web_light_sq_SI.svg" alt="Sign In with Google" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user