From 5eb6ae0684e72d3ad57384ece90333a5de10d7e0 Mon Sep 17 00:00:00 2001 From: dis-may Date: Tue, 30 Apr 2024 12:31:33 +1200 Subject: [PATCH 1/2] Added Google Sign-in from Header element on the front-end --- web/services/firebase.tsx | 23 +++++++++++++++++++++++ web/src/components/Header.tsx | 5 +++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 web/services/firebase.tsx diff --git a/web/services/firebase.tsx b/web/services/firebase.tsx new file mode 100644 index 0000000..652931f --- /dev/null +++ b/web/services/firebase.tsx @@ -0,0 +1,23 @@ +import { initializeApp } from 'firebase/app'; +import { getAuth, GoogleAuthProvider, signInWithPopup } from 'firebase/auth'; + +const firebaseConfig = { + apiKey:"AIzaSyBox7z0b2SBEnz0v6qmQjFx3QfUJcG099U", + authDomain:"volunteerclub-14b7a.firebaseapp.com", + projectId:"volunteerclub-14b7a", + storageBucket:"volunteerclub-14b7a.appspot.com", + messagingSenderId:"765497707892", + appId:"1:765497707892:web:d1fb4e8f77881366037021", + measurementId:"G-TLM9P3DCKS", + }; + +// Check if Firebase is already initialized to prevent re-initialization +const app = initializeApp(firebaseConfig); + +// Export Firebase authentication service +export const auth = getAuth(app); + +export const handleGoogle = async () => { + const provider = await new GoogleAuthProvider(); + return signInWithPopup(auth, provider); + } \ No newline at end of file diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index df1dfea..ad29e56 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -1,4 +1,5 @@ -import "../styles/componentStyles/Header.css" +import "../styles/componentStyles/Header.css"; +import { handleGoogle } from "../../services/firebase.tsx"; function Header() { return ( @@ -11,7 +12,7 @@ function Header() {
From d4ce183de437aaafa23c543ef56b6decac5d3655 Mon Sep 17 00:00:00 2001 From: May Gan <119158272+dis-may@users.noreply.github.com> Date: Wed, 1 May 2024 14:53:39 +1200 Subject: [PATCH 2/2] Removed misleading comment --- web/services/firebase.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/services/firebase.tsx b/web/services/firebase.tsx index 652931f..728c580 100644 --- a/web/services/firebase.tsx +++ b/web/services/firebase.tsx @@ -11,7 +11,6 @@ const firebaseConfig = { measurementId:"G-TLM9P3DCKS", }; -// Check if Firebase is already initialized to prevent re-initialization const app = initializeApp(firebaseConfig); // Export Firebase authentication service @@ -20,4 +19,4 @@ export const auth = getAuth(app); export const handleGoogle = async () => { const provider = await new GoogleAuthProvider(); return signInWithPopup(auth, provider); - } \ No newline at end of file + }