firebase / firebase/firebase-js-sdk

signInWithPopup With Multi-Tenancy

Open
#8,617 1 comment 0 reactions 0 assignees View on GitHub
api: auth feature request
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### Operating System

Windows 11 Pro

### Environment (if applicable)

Microsoft Edge, React

### Firebase SDK Version

11.0.1

### Firebase SDK Product(s)

Auth

### Project Tooling

React app with MUI.

### Detailed Problem Description

It appears that obtaining the `email address` from `signInWithPopup` prior to authentication is not feasible. This limitation necessitates a cumbersome workflow where users must first enter their `email address` in a field, which then allows for the correct tenant to be set in `auth.tenant`. This setup can lead to a frustrating user experience, as it introduces unnecessary steps. Please refer to the Proof of Concept (PoC) for further details.

### Steps and code to reproduce issue

```js
const handleGoogle = async () => {
auth.useDeviceLanguage();

try {
// The auth need to be assigned the proper tenantId or this would fail, however, we can only fetch the tenant Id once the user has picked his preferred account...
const userCredential = await signInWithPopup(
auth,
new GoogleAuthProvider()
);
const { isNewUser } = getAdditionalUserInfo(userCredential);

if (isNewUser) {
await auth.currentUser.delete();
throw new Error(`${email} is not registered.`);
} else {
--- SNIP ---
}
} catch (error) {
--- SNIP ----
}
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.