aditya-rAj19 commited on
Commit
dc6ff49
·
1 Parent(s): 1e446d8

fix: switch to redirect-only sign-in, remove popup (blocked by browsers)

Browse files
Files changed (1) hide show
  1. frontend/src/pages/LandingPage.jsx +4 -11
frontend/src/pages/LandingPage.jsx CHANGED
@@ -1,7 +1,7 @@
1
  import { useState } from 'react';
2
  import { useNavigate } from 'react-router-dom';
3
  import { motion } from 'framer-motion';
4
- import { auth, googleProvider, signInWithPopup, signInWithRedirect, getRedirectResult } from '../firebase';
5
  import useAuth, { saveSession, daysLeft } from '../hooks/useAuth';
6
  import Aurora from '../components/ui/Aurora';
7
  import SplitText from '../components/ui/SplitText';
@@ -67,18 +67,11 @@ export default function LandingPage() {
67
  setSigningIn(true);
68
  setError('');
69
  try {
70
- const result = await signInWithPopup(auth, googleProvider);
71
- saveSession(result.user, '');
72
- result.user.getIdToken(false).then(t => localStorage.setItem('df_token', t)).catch(() => {});
73
- navigate('/app');
74
  } catch (err) {
75
  console.error('[Firebase Auth Error]', err?.code, err?.message);
76
- if (err?.code === 'auth/popup-closed-by-user') {
77
- // user dismissed — no toast needed
78
- } else if (err?.code === 'auth/popup-blocked') {
79
- // Popup blocked — fall back to redirect (no popup permission needed)
80
- await signInWithRedirect(auth, googleProvider);
81
- } else if (err?.code === 'auth/unauthorized-domain') {
82
  setError('This domain is not authorised in Firebase. Add it to Authorised Domains in Firebase Console.');
83
  } else if (err?.code === 'auth/operation-not-allowed') {
84
  setError('Google sign-in is not enabled. Enable it in Firebase Console → Authentication → Sign-in method.');
 
1
  import { useState } from 'react';
2
  import { useNavigate } from 'react-router-dom';
3
  import { motion } from 'framer-motion';
4
+ import { auth, googleProvider, signInWithRedirect, getRedirectResult } from '../firebase';
5
  import useAuth, { saveSession, daysLeft } from '../hooks/useAuth';
6
  import Aurora from '../components/ui/Aurora';
7
  import SplitText from '../components/ui/SplitText';
 
67
  setSigningIn(true);
68
  setError('');
69
  try {
70
+ await signInWithRedirect(auth, googleProvider);
71
+ // Page will redirect to Google — code below won't run until user returns
 
 
72
  } catch (err) {
73
  console.error('[Firebase Auth Error]', err?.code, err?.message);
74
+ if (err?.code === 'auth/unauthorized-domain') {
 
 
 
 
 
75
  setError('This domain is not authorised in Firebase. Add it to Authorised Domains in Firebase Console.');
76
  } else if (err?.code === 'auth/operation-not-allowed') {
77
  setError('Google sign-in is not enabled. Enable it in Firebase Console → Authentication → Sign-in method.');