Skip to content

new beforeAuthStateChanged's onAbort doesn't work #6311

Closed
@marcusx2

Description

@marcusx2
<script type="module">
		import { initializeApp, FirebaseError } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-app.js";
		import { getAuth, GoogleAuthProvider, signInWithPopup } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-auth.js";
		
		//your firebase config
		const firebaseConfig = {
		  
		};
		const app = initializeApp(firebaseConfig);
		const auth = getAuth(app);
		const provider = new GoogleAuthProvider();
		provider.addScope('profile');
		provider.addScope('email');
		signInWithPopup(auth, provider);
		
		auth.beforeAuthStateChanged((user) => {
		  throw new Error('stop sign in 1');
		}, () => {
			console.log("beforeAuthStateChanged Abort 1");
		});
		
		auth.beforeAuthStateChanged((user) => {
		  throw new Error('stop sign in 2');
		}, () => {
			console.log("beforeAuthStateChanged Abort 2");
		});
		
		auth.onAuthStateChanged((user) => {
		  if (user) {
			console.log("after");
			const uid = user.uid;
			// ...
		  } else {
			// User is signed out
			// ...
		  }
		});
		
  </script>

the onAbort never runs. It is said about the onAbort

callback triggered if a later beforeAuthStateChanged() callback throws, allowing you to undo any side effects.

well, I called beforeAuthStateChanged twice but the onAbort was never called.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions