-
Notifications
You must be signed in to change notification settings - Fork 763
Fix: Resolve dropdown conflicts between search and profile menus #4130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f7799b8
4b7cdd5
e3d2460
50ece82
774598d
4c6e1c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { useState } from "react"; | ||
| import { sendEmailVerification } from "firebase/auth"; | ||
| import { useAuth } from "../hooks/useAuth"; | ||
| import { useNavigate } from "react-router-dom"; | ||
|
|
||
| export default function EmailVerificationPrompt() { | ||
| const { user } = useAuth(); | ||
| const navigate = useNavigate(); | ||
|
|
||
| const [message, setMessage] = useState(""); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const resendEmail = async () => { | ||
| try { | ||
| setLoading(true); | ||
|
|
||
| await sendEmailVerification(user); | ||
|
|
||
| setMessage("Verification email sent successfully."); | ||
| } catch (error) { | ||
| setMessage(error.message); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| const checkVerification = async () => { | ||
| try { | ||
| await user.reload(); | ||
|
|
||
| if (user.emailVerified) { | ||
| navigate("/dashboard"); | ||
| } else { | ||
| setMessage("Email is still not verified."); | ||
| } | ||
|
|
||
| } catch (error) { | ||
| setMessage(error.message); | ||
| } | ||
| }; | ||
|
Comment on lines
+28
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent overlapping async actions for resend/check flows.
Suggested fix const [message, setMessage] = useState("");
const [loading, setLoading] = useState(false);
+ const [checking, setChecking] = useState(false);
@@
const checkVerification = async () => {
try {
+ setChecking(true);
await user.reload();
@@
} catch (error) {
setMessage(error.message);
+ } finally {
+ setChecking(false);
}
};
@@
<button
onClick={resendEmail}
- disabled={loading || !canUseVerificationApis}
+ disabled={loading || checking || !canUseVerificationApis}
>
{loading ? "Sending..." : "Resend verification email"}
</button>
@@
<button
onClick={checkVerification}
- disabled={loading || !canUseVerificationApis}
+ disabled={loading || checking || !canUseVerificationApis}
>
- I've verified, continue
+ {checking ? "Checking..." : "I've verified, continue"}
</button>Also applies to: 62-74 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| return ( | ||
| <div className="min-h-screen flex items-center justify-center"> | ||
| <div className="max-w-md text-center p-6 rounded-lg border"> | ||
|
|
||
| <h1 className="text-2xl font-bold mb-4"> | ||
| Verify your email | ||
| </h1> | ||
|
|
||
| <p className="mb-6"> | ||
| We sent a verification link to: | ||
| </p> | ||
|
|
||
| <strong> | ||
| {user?.email} | ||
| </strong> | ||
|
|
||
| <div className="mt-6 flex flex-col gap-3"> | ||
|
|
||
| <button | ||
| onClick={resendEmail} | ||
| disabled={loading} | ||
| > | ||
| {loading ? "Sending..." : "Resend verification email"} | ||
| </button> | ||
|
|
||
|
|
||
| <button | ||
| onClick={checkVerification} | ||
| > | ||
| I've verified, continue | ||
| </button> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
| {message && ( | ||
| <p className="mt-4"> | ||
| {message} | ||
| </p> | ||
| )} | ||
|
|
||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,8 @@ import { | |||||||||||||||||||||||
| signOut, | ||||||||||||||||||||||||
| GoogleAuthProvider, | ||||||||||||||||||||||||
| signInWithPopup, | ||||||||||||||||||||||||
| updateProfile | ||||||||||||||||||||||||
| updateProfile, | ||||||||||||||||||||||||
| sendEmailVerification | ||||||||||||||||||||||||
| } from 'firebase/auth' | ||||||||||||||||||||||||
| import { auth } from '../config/firebase' | ||||||||||||||||||||||||
| import { AuthContext } from './AuthContext' | ||||||||||||||||||||||||
|
|
@@ -57,6 +58,9 @@ export function AuthProvider({ children }) { | |||||||||||||||||||||||
| const signup = async (email, password, displayName) => { | ||||||||||||||||||||||||
| if (!auth) throw new Error("Authentication service is not configured. Please check your environment variables and authentication provider setup. Refer to the project setup documentation for configuration instructions.") | ||||||||||||||||||||||||
| const result = await createUserWithEmailAndPassword(auth, email, password) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| await sendEmailVerification(result.user) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
60
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In the Firebase JS SDK, the Citations:
🏁 Script executed: # First, find the AuthProvider.jsx file
fd -type f -name "AuthProvider.jsx"Repository: anurag3407/career-pilot Length of output: 238 🏁 Script executed: # Find the AuthProvider.jsx file
fd "AuthProvider.jsx"Repository: anurag3407/career-pilot Length of output: 105 🏁 Script executed: # Read the AuthProvider.jsx file to see lines 60-63
cat -n frontend/src/context/AuthProvider.jsx | sed -n '50,75p'Repository: anurag3407/career-pilot Length of output: 1284 🏁 Script executed: # Find and check Register.jsx to see how signup errors are handled
fd "Register.jsx" | head -5Repository: anurag3407/career-pilot Length of output: 99 🏁 Script executed: # Read Register.jsx to see how signup is called and errors are handled
cat -n frontend/src/pages/Register.jsx | head -150Repository: anurag3407/career-pilot Length of output: 6024 Don't fail the whole signup on verification-email delivery failure. At Line 62, Suggested fix const result = await createUserWithEmailAndPassword(auth, email, password)
-
- await sendEmailVerification(result.user)
+ try {
+ await sendEmailVerification(result.user)
+ } catch (verificationError) {
+ // Account is already created; keep signup successful and handle notification separately.
+ console.warn('Failed to send verification email:', verificationError)
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| if (displayName) { | ||||||||||||||||||||||||
| await updateProfile(result.user, { displayName }) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { useEffect } from 'react' | ||
|
|
||
| /** | ||
| * Custom hook that triggers a callback when clicking outside of a referenced element | ||
| * @param {React.RefObject} ref - React ref object pointing to the element to monitor | ||
| * @param {Function} callback - Function to call when clicking outside | ||
| */ | ||
| const useClickOutside = (ref, callback) => { | ||
| useEffect(() => { | ||
| const handleClickOutside = (event) => { | ||
| if (ref.current && !ref.current.contains(event.target)) { | ||
| callback() | ||
| } | ||
| } | ||
|
|
||
| // Add event listener when component mounts | ||
| document.addEventListener('mousedown', handleClickOutside) | ||
| document.addEventListener('touchstart', handleClickOutside) | ||
|
|
||
| // Cleanup event listeners when component unmounts | ||
| return () => { | ||
| document.removeEventListener('mousedown', handleClickOutside) | ||
| document.removeEventListener('touchstart', handleClickOutside) | ||
| } | ||
| }, [ref, callback]) | ||
| } | ||
|
|
||
| export default useClickOutside |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 24364
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 2544
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 95
🏁 Script executed:
rg -n "sendEmailVerification" frontend/src --type js -B2 -A2Repository: anurag3407/career-pilot
Length of output: 1560
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 95
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 672
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 236
🏁 Script executed:
Repository: anurag3407/career-pilot
Length of output: 1180
Guard Firebase-user API calls before invoking verification methods.
Lines 30 and 32 assume
useris a FirebaseUserobject withreload()method andemailVerifiedproperty. TheAuthProviderdev-mode fallback creates a mock user without these members, causing runtime errors in local development. Additionally, line 71's check button lacks aloadingdisabled state, allowing concurrent invocations.🤖 Prompt for AI Agents