Azure-Samples / active-directory-b2c-advanced-policies

Sample for use with Azure AD B2C with Custom Policies.
http://aka.ms/aadb2ccustom
MIT License
218 stars 143 forks source link

How to check whether a user is exist in firebase before sending reset email? #70

Closed athulya-ratheesh closed 3 years ago

athulya-ratheesh commented 4 years ago

I am using Firebase authentication in my React Native application development. The problem I am facing is On implementing reset password functionality users receiving emails even though they are not a registered user in Firebase.

1) How can I send reset password emails only for Firebase registered users ?

2) How can I achieve this from frontend side(React Native) ?

Here is the code I am using.


import firebase from '@react-native-firebase/app';

export function onForgotPassword(email: string) {
  firebase
    .auth()
    .sendPasswordResetEmail(email)
    .then(() => {
      // alert('Please check your email...');
    })
    .catch((e) => {
      NLog.log(e);
    });
}

Thanks in advance.

athulya-ratheesh commented 3 years ago

I have solved this issue using fetchSignInMethodsForEmail to check if an email address is known for any provider before trying to send a reset message to it.