@@ -106,7 +106,6 @@ Once the user is logged in you can retrieve the currently logged in user:
106106### Fetch providers for email
107107Want 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
138168Pass in at least one of ` displayName ` and ` photoURL ` .
139169The logged in user will be updated, but for ` getCurrentUser ` to reflect the change you'll need to do a logout-login.
0 commit comments