Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit f8fb887

Browse files
Add Email Link Authentication #665 (also needs fetchSignInMethodsForEmail - doc)
1 parent d3c5b1b commit f8fb887

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

docs/AUTHENTICATION.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ Once the user is logged in you can retrieve the currently logged in user:
106106
### Fetch providers for email
107107
Want to know which auth providers are associated with an emailaddress?
108108

109-
110109
<details>
111110
<summary>Native API</summary>
112111

@@ -134,6 +133,37 @@ Want to know which auth providers are associated with an emailaddress?
134133
```
135134
</details>
136135

136+
### Fetch sign-in methods for email
137+
Both email-password login and email-link login are `password` providers, so by just using `fetchProvidersForEmail`
138+
you won't be able to differentiate between those login methods. That's where `fetchSignInMethodsForEmail` comes in.
139+
140+
<details>
141+
<summary>Native API</summary>
142+
143+
```typescript
144+
const emailAddress = "[email protected]";
145+
firebase.fetchSignInMethodsForEmail(emailAddress).then((methods: Array<string>) => {
146+
console.log(`Sign-in methods for ${emailAddress}: ${JSON.stringify(methods)}`);
147+
});
148+
```
149+
</details>
150+
151+
<details>
152+
<summary>Web API</summary>
153+
154+
```js
155+
const user = firebaseWebApi.auth().currentUser;
156+
if (!user || !user.email) {
157+
console.log("Can't fetch sign-in methods; no user with an emailaddress logged in.");
158+
return;
159+
}
160+
161+
firebaseWebApi.auth().fetchSignInMethodsForEmail(user.email)
162+
.then(result => console.log(`Sign-in methods for ${user.email}: ${JSON.stringify(result)}`))
163+
.catch(error => console.log("Fetch Sign-in methods for Email error: " + error));
164+
```
165+
</details>
166+
137167
### Updating a profile
138168
Pass in at least one of `displayName` and `photoURL`.
139169
The logged in user will be updated, but for `getCurrentUser` to reflect the change you'll need to do a logout-login.

0 commit comments

Comments
 (0)