WIP Custom auth handler / login

Forgot password is not working
This commit is contained in:
Michael
2021-08-05 21:12:12 +02:00
parent 56bc4f24a9
commit 67631d2ba8
11 changed files with 283 additions and 991 deletions

33
utils/AuthContext.js Normal file
View File

@@ -0,0 +1,33 @@
import React, { createContext, useContext, useState } from "react";
import { supabase } from "utils/supabaseClient";
// create a context for authentication
const AuthContext = createContext();
export const AuthProvider = ({ children }) => {
// create state values for user data and loading
const [user, setUser] = useState();
const [loading, setLoading] = useState(true);
// create signUp, signIn, signOut functions
const value = {
signUp: (data) => supabase.auth.signUp(data),
signIn: (data) => supabase.auth.signIn(data),
signOut: () => supabase.auth.signOut(),
resetPassword: (data) => supabase.auth.api.resetPasswordForEmail(data),
user,
};
// use a provider to pass down the value
return (
<AuthContext.Provider value={value}>
{!loading && children}
</AuthContext.Provider>
);
};
// export the useAuth hook
export const useAuth = () => {
return useContext(AuthContext);
};