connection base prisma + postgres + login ok
This commit is contained in:
24
src/providers/AuthProvider.tsx
Normal file
24
src/providers/AuthProvider.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
'use client';
|
||||
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { SessionProvider } from 'next-auth/react';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
|
||||
const AuthContext = createContext<any>(null);
|
||||
|
||||
function AuthInner({ children }: { children: React.ReactNode }) {
|
||||
const auth = useAuth();
|
||||
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
|
||||
}
|
||||
|
||||
export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
return (
|
||||
<SessionProvider>
|
||||
<AuthInner>{children}</AuthInner>
|
||||
</SessionProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export function useAuthContext() {
|
||||
return useContext(AuthContext);
|
||||
}
|
||||
Reference in New Issue
Block a user