generated from prokawsar/dashboard-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/prokawsar/paper-calc
- Loading branch information
Showing
4 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores' | ||
import { supabase } from '$lib/db/supabaseClient' | ||
import Button from '$lib/elements/Button.svelte' | ||
import Input from '$lib/elements/Input.svelte' | ||
import { redirect } from '@sveltejs/kit' | ||
let email = '' | ||
let password = '' | ||
let otp = '' | ||
let isOtpSent = false | ||
|
@@ -13,6 +17,16 @@ | |
const verifyOTP = () => { | ||
if (!otp) return | ||
} | ||
const handleLogin = async () => { | ||
if (!email || !password) return | ||
console.log(email, password) | ||
const { data, error } = await supabase.auth.signInWithPassword({ email, password }) | ||
if (error) { | ||
return | ||
} | ||
return redirect(300, '/') | ||
} | ||
</script> | ||
|
||
<svelte:head> | ||
|
@@ -24,7 +38,7 @@ | |
<div class="w-full bg-gradient-to-r from-transparent via-slate-600/10 to-transparent p-[1px]" /> | ||
|
||
<form class="flex w-full flex-col gap-3 items-center"> | ||
{#if isOtpSent} | ||
<!-- {#if isOtpSent} | ||
<Input | ||
required | ||
type="text" | ||
|
@@ -33,15 +47,27 @@ | |
placeholder="******" | ||
/> | ||
<Button type="submit" text="Login with OTP" on:click={verifyOTP} /> | ||
{:else} | ||
<Input | ||
required | ||
type="email" | ||
bind:value={email} | ||
classNames="!w-full text-center" | ||
placeholder="Type your email" | ||
/> | ||
<Button type="submit" text="Send OTP" on:click={handleSendOTP} /> | ||
{/if} | ||
{:else} --> | ||
<Input | ||
required | ||
type="email" | ||
bind:value={email} | ||
classNames="!w-full text-center" | ||
placeholder="Type your email" | ||
/> | ||
<Input | ||
required | ||
type="password" | ||
bind:value={password} | ||
classNames="!w-full text-center font-bold" | ||
placeholder="*******" | ||
/> | ||
<Button type="submit" text="Login" on:click={handleLogin} /> | ||
<!-- {/if} --> | ||
</form> | ||
|
||
<p class="text-center text-slate-500 mt-10"> | ||
Forget password? Need a new account? <br /> | ||
Contact: <email>[email protected]</email> | ||
</p> | ||
</section> |