Files
supanextail/components/Auth.js
Michael 67631d2ba8 WIP Custom auth handler / login
Forgot password is not working
2021-08-05 21:12:12 +02:00

43 lines
1.2 KiB
JavaScript

/*
This is the Auth component. It will allow your user to login.
By default, it is available with the auth.js page, but you can use it everywhere you want!
CONFIGURE THE AUTH COMPONENT LINE 30
You can select your auth providers, or just keep the email/password. You can
check the providers available here: https://supabase.io/docs/guides/auth
*/
import Login from "./UI/Login";
import { supabase } from "utils/supabaseClient";
import { useAuth } from "utils/Authcontext";
const Container = (props) => {
const { user, signOut } = useAuth();
if (user)
return (
<div className='w-80 md:w-96 order-first lg:order-last'>
<p>Hello {user.email}! 👋 You are already logged in</p>
<button className='btn btn-primary' onClick={() => signOut()}>
Sign out
</button>
</div>
);
return props.children;
};
const AuthComponent = () => {
const { signUp, signIn, signOut, resetPassword } = useAuth();
return (
<Container supabaseClient={supabase}>
<Login
signUp={signUp}
signIn={signIn}
signOut={signOut}
resetPassword={resetPassword}
/>
</Container>
);
};
export default AuthComponent;