Angular Firebase not able to invoke Reset Password

29 Views Asked by At

My code is throwing error Uncaught TypeError: _baseUrl.resetPassword is not a function when I am trying to invoke this function.

Following is how I have configured firebase object

    var firebaseConfig = {
        apiKey: "my api key",
        authDomain: "my-domain.firebaseapp.com",
        databaseURL: "https://collection-name.firebaseio.com",
        projectId: "my-project-id-1111",
        storageBucket: "my-storage-bucket.appspot.com",
        messagingSenderId: "XXXXXXXXXX",
        appId: "1:XXXXXXXXX:web:XXXXXXXXXX"
        };

    // Initialize Firebase
    var _firebase = firebase.initializeApp(firebaseConfig);
    var _baseUrl = _firebase.database().ref("web/data");
    var _baseAuth = _firebase.auth();

    function resetPassword(userEmail) {
        _baseUrl.resetPassword({
            email: userEmail
        }, function(error) {
            console.log(error);
            if (error === null) {
                return false;
            } else {
                return error;
            }
        });
    }

when I call the resetPassowrd function it throws an error. Uncaught TypeError: _baseUrl.resetPassword is not a function

I have checked through debugging that I am receiving "_baseUrl" in my function but it does not have a method resetPassword

Please help and Thanks in advance

1

There are 1 best solutions below

0
RawatAlka On BEST ANSWER
var firebaseConfig = {
        apiKey: "my api key",
        authDomain: "my-domain.firebaseapp.com",
        databaseURL: "https://collection-name.firebaseio.com",
        projectId: "my-project-id-1111",
        storageBucket: "my-storage-bucket.appspot.com",
        messagingSenderId: "XXXXXXXXXX",
        appId: "1:XXXXXXXXX:web:XXXXXXXXXX"
        };

    // Initialize Firebase
    var _firebase = firebase.initializeApp(firebaseConfig);
    var _baseUrl = _firebase.database().ref("web/data");
    var _baseAuth = _firebase.auth();`enter code here`


         function resetPassword(userEmail) {
           _baseAuth.sendPasswordResetEmail(
                userEmail, actionCodeSettings=null)
                .then(function() {
                  console.log('email sent');
                })
                .catch(function(error) {
                  console.log('error occurred');
                });



        }

I have used this function to reset the password and it is working fine.