Open
Description
Describe your environment
- Operating System version:
Arch Linux
- Browser version:
103.0.2 (64-bit)
- Firebase UI version:
6.x
- Firebase SDK version:
9.10.0
Describe the problem
The following error is thrown when using Persistence.NONE
and trying to create an auth instance on a browser which has its cookies disabled.
Uncaught (in promise) FirebaseError: Firebase: The current environment does not support the specified persistence type. (auth/unsupported-persistence-type).
FirebaseError index.esm2017.js:791
create index.esm2017.js:819
createErrorInternal index-4dc22a28.js:474
_assert index-4dc22a28.js:480
_validatePersistenceArgument index.esm2017.js:201
setPersistence index.esm2017.js:749
Cn esm.js:347
Login index.tsx:76
I believe the root cause behind this is the following code.
firebaseui-web/javascript/widgets/authui.js
Lines 144 to 148 in 51c8f7a
As you can see, this code tries to set Persistence.SESSION
even when I have previously set Persistence.NONE
in my firebase/auth
instance.
Steps to reproduce:
- Set browser to reject cookies for your Firebase based application address, for example
localhost:3001
in my case. - Try to open page which is creating firebase instance, something like this (react code). Main idea is to set
auth
toPersistence.NONE
and then try to create firebaseui auth instance.
export default function Login() {
const [ready, setReady] = useState(false);
const elementRef = useRef<HTMLDivElement>(null);
useEffect(() => {
auth.setPersistence(firebase.auth.Auth.Persistence.NONE).then(() => {
firebaseui.auth.AuthUI.prototype.
setReady(true);
});
}, []);
useEffect(() => {
if (!ready) return;
const widget =
firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(auth);
if (elementRef.current) {
widget.start(elementRef.current, uiConfig);
}
return () => {
widget.reset();
};
}, [ready, elementRef]);
// code
return (
<div ref={elementRef} />
);
}
How to fix:
I believe this.tempAuth_.setPersistence
should be using persistence information from firebase.auth
instance passed to it.