-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🍀🚀 ↣ Successfully navigating authentication routes between #18 and th…
…e Supabase configuration
- Loading branch information
1 parent
2ba259c
commit d10b1f5
Showing
2 changed files
with
129 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useState } from "react"; | ||
import { supabase } from "../../pages/supabaseClient"; | ||
|
||
export default function Auth() { | ||
const [loading, setLoading] = useState(false); | ||
const [email, setEmail] = useState(''); | ||
const handleLogin = async (e) => { | ||
e.preventDefault(); | ||
try { | ||
setLoading(true); | ||
const { error } = await supabase.auth.signIn({ email }); | ||
if (error) throw error; | ||
alert('Check your email for the login info'); | ||
} catch (error) { | ||
alert(error.error_description || error.message); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
|
||
return ( | ||
<div className="container mx-auto text-center w-72"> | ||
<div className="col-6 form-widget" aria-live="polite"> | ||
<h1 className="header text-3xl py-3 text-gray-600">Login</h1> | ||
<p className="text-xs text-gray-500 pb-3">Sign in via magic link with your email</p> | ||
{loading ? ( | ||
'Sending magic link...' | ||
) : ( | ||
<form onSubmit={handleLogin}> | ||
<input type="email" | ||
name="email" | ||
class="mt-1 px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1" | ||
placeholder="your email" | ||
id="website" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
<button class="my-3 w-36 text-xs h-8 rounded-full text-gray-50 bg-indigo-600 hover:bg-indigo-700"> | ||
Send Magic link | ||
</button> | ||
</form> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
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