Skip to content

return success/error result from signOut instead of silently swa… - #346

Open
khushboo-khatoon wants to merge 1 commit into
Nitya-003:mainfrom
khushboo-khatoon:fix/signout-error-feedback
Open

return success/error result from signOut instead of silently swa…#346
khushboo-khatoon wants to merge 1 commit into
Nitya-003:mainfrom
khushboo-khatoon:fix/signout-error-feedback

Conversation

@khushboo-khatoon

Copy link
Copy Markdown
Contributor

signOut() failure is silently swallowed with no user feedback

Fixes #342

Description

Previously, signOut() in the useAuth hook caught any error from firebaseSignOut and only logged it to the console. It didn't return anything, throw, or expose any error state to the caller — so any UI component calling signOut() had no way to know whether sign-out actually succeeded or failed.

This meant that if firebaseSignOut failed (e.g. due to a network issue), the app could still proceed as if the user had successfully signed out, even though they remained authenticated — a security/trust concern, especially on shared devices.

Changes

  • signOut() now returns Promise<{ success: boolean; error?: unknown }> instead of returning nothing.
  • On success, it returns { success: true }.
  • On failure, it logs the error (for debugging) and returns { success: false, error }.
  • The early-return case (when Firebase isn't configured) now also returns { success: false } for a consistent return shape across all code paths.

File

frontend/hooks/useAuth.ts

Before

const signOut = async () => {
  if (!isFirebaseConfigured || !auth) return;
  try {
    await firebaseSignOut(auth);
  } catch (error) {
    console.error('Error signing out: ', error);
  }
};

After

const signOut = async (): Promise<{ success: boolean; error?: unknown }> => {
  if (!isFirebaseConfigured || !auth) return { success: false };
  try {
    await firebaseSignOut(auth);
    return { success: true };
  } catch (error) {
    console.error('Error signing out: ', error);
    return { success: false, error };
  }
};

Note

signOut() isn't currently called anywhere in the codebase yet (verified via a full search — no "Sign Out" UI exists at this time). This fix ensures signOut() returns a proper { success, error } result so that whenever a Sign Out UI is implemented in the future, the calling component can immediately show appropriate feedback (e.g. a toast on failure) instead of silently assuming success.

How to Test

  1. Since there's no calling UI yet, this can be tested by temporarily invoking signOut() from a test component or the browser console after import, and confirming:
    • A successful sign-out resolves with { success: true }.
    • A simulated failure (e.g. mock firebaseSignOut to reject) resolves with { success: false, error } instead of throwing or resolving with undefined.

Impact

Ensures that once a Sign Out feature is built, users will always receive accurate feedback about whether they were actually signed out, preventing a scenario where a user believes they're logged out on a device while still authenticated.

Checklist

  • Code builds and runs locally
  • No unrelated code changes
  • No new lint/type errors introduced
  • Verified signOut() has no existing callers to update

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@khushboo-khatoon is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

@khushboo-khatoon

Copy link
Copy Markdown
Contributor Author

hey @Nitya-003 ,

PR is now ready to review and merge .

thank u ( :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signOut() failure is silently swallowed with no user feedback

1 participant