-
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.
basic admin side login + managing and adding events
@AkshadGawde needs lot of ui refinement, default style sheet makes it look very messy. make sure you have the env setup locally for testing
- Loading branch information
1 parent
eca4f8c
commit 72372db
Showing
9 changed files
with
2,264 additions
and
80 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
.next | ||
*.local | ||
.env.local |
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,20 @@ | ||
import { initializeApp } from "firebase/app"; | ||
import { getAuth } from 'firebase/auth'; | ||
import { getFirestore } from 'firebase/firestore'; | ||
|
||
|
||
const firebaseConfig = { | ||
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY, | ||
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN, | ||
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID, | ||
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET, | ||
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID, | ||
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID, | ||
}; | ||
|
||
const app = initializeApp(firebaseConfig); | ||
const db = getFirestore(app); | ||
const auth = getAuth(app); | ||
|
||
|
||
export { db , auth}; |
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,25 @@ | ||
// lib/withAuth.js | ||
import { useEffect } from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import { auth } from '../lib/firebase'; // Import Firebase auth | ||
|
||
const withAuth = (WrappedComponent) => { | ||
return (props) => { | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
const unsubscribe = auth.onAuthStateChanged((user) => { | ||
if (!user) { | ||
// If no user, redirect to login page | ||
router.push('/login'); | ||
} | ||
}); | ||
|
||
return () => unsubscribe(); // Cleanup subscription on unmount | ||
}, []); | ||
|
||
return <WrappedComponent {...props} />; | ||
}; | ||
}; | ||
|
||
export default withAuth; |
Oops, something went wrong.