quickstart-js icon indicating copy to clipboard operation
quickstart-js copied to clipboard

Error: authObj.authWithPassword is not a function

Open Gajendrasinh opened this issue 10 years ago • 2 comments

when try to login using Email and passsword Error: Error: authObj.authWithPassword is not a function

When try to login using google Error: authObj.$authWithOAuthPopup is not a function

"https://www.gstatic.com/firebasejs/3.0.3/firebase.js"

Code: myApp.controller('LoginCtrl', ['$scope' ,'$state', '$firebaseAuth', '$firebaseArray', function($scope, $state, $firebaseAuth, $firebaseArray) {

   // var rootRef = firebase.database().ref();

    var authObj = $firebaseAuth();

    $scope.login = function () {

        authObj.authWithPassword({
          email    : $scope.loginEmail,
          password : $scope.loginPassword
        }, function(error, authData) {
          if (error) {
            console.log("Login Failed!", error);
          } else {
            console.log("Authenticated successfully with payload:", authData);
            $state.go('home');
          }
        });

    }

    firebaseAuthLogin = function(provider){
        console.log(provider);
        authObj.$authWithOAuthPopup(provider).then(function (authData) {
            console.log("Authenticated successfully with provider " + provider +" with payload:", authData);
        }).catch(function (error) {
            console.error("Authentication failed:", error);
        });

    }

    $scope.googleLogin = function () {
       firebaseAuthLogin('google');
    }

}]);

Gajendrasinh avatar Jul 13 '16 09:07 Gajendrasinh

Hi, I don;t know if you still looking for the answer or not but I did find another threat with the same problem and the solution worked for me. Here is the text

try $signInWithEmailAndPassword

See documentation: https://github.com/firebase/angularfire/blob/master/docs/reference.md#signinwithemailandpasswordemail-password

The answer was provided by Aaron Saunders in this threat http://stackoverflow.com/questions/38670049/authwithpassword-is-not-a-function-in-angularfire-2-x

enumus avatar Aug 03 '16 21:08 enumus

@enumus thx for helping :)

nicolasgarnier avatar Aug 03 '16 21:08 nicolasgarnier