marvelai-org / marvel-platform

This is the marvel teaching assistant ai project.
https://app.marvelai.org/
MIT License
18 stars 98 forks source link

Add Google Authentication #80

Open bkb-Git opened 4 months ago

bkb-Git commented 4 months ago

Add Google Authentication to Existing Auth System using Firebase Auth

Description

Enhance the existing authentication system by adding the option for users to sign in and sign up using their Google accounts. This will provide an additional, convenient authentication method.

image

Tasks

  1. Enable Google Authentication in Firebase:
    • Go to the Firebase Console and enable Google Authentication.
  2. Install Firebase Dependencies:
    • Ensure the firebase package is installed and up-to-date.
  3. Configure Firebase for Google Auth:
    • Update the Firebase configuration to include the Google Auth provider.
  4. Add Google Sign-In Button to SignInForm.jsx:
    • Add a Google Sign-In button to the SignInForm.jsx component.
    • Style the button to match the application's theme.
  5. Add Google Sign-Up Button to SignUpForm.jsx:
    • Add a Google Sign-Up button to the SignUpForm.jsx component.
    • Style the button to match the application's theme.
  6. Implement Google Sign-In/Sign-Up Logic:
    • Implement the sign-in and sign-up logic using Firebase Auth's Google provider.
    • Handle success and error scenarios appropriately.
  7. Update Authentication State:
    • Update the Redux store or context to reflect the user's authentication state.
    • Ensure the UI updates correctly based on the authentication state.
  8. Testing:
    • Thoroughly test the Google Sign-In and Sign-Up functionality on different devices and browsers.
    • Ensure that sign-in, sign-up, and error handling work as expected.

Files and Locations

Acceptance Criteria

Additional Information

References


Example Code Snippet for Google Sign-In/Sign-Up


import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth";
import { useDispatch } from "react-redux";
import { setUser } from "./userSlice"; // Example Redux action to set the user

const auth = getAuth();
const provider = new GoogleAuthProvider();

const handleGoogleSignIn = async () => {
  try {
    const result = await signInWithPopup(auth, provider);
    const user = result.user;
    // Dispatch user data to Redux store or update context
    dispatch(setUser(user));
  } catch (error) {
    console.error("Error signing in with Google: ", error);
  }
};

// In your SignInForm.jsx and SignUpForm.jsx
<button onClick={handleGoogleSignIn}>Sign in with Google</button>
<button onClick={handleGoogleSignIn}>Sign up with Google</button>
aravindinduri commented 1 month ago

can i work on this