faisaljanjua
faisaljanjua

Reputation: 936

Firebase Auth AngularJs

creating a login app in AngularJS with firebase, and getting these issues.

1 .TypeError: auth.$createUser is not a function

  1. Error: permission_denied: Client doesn't have permission to access the desired data.
    var app = angular.module('weatherApp',
        ['ngRoute', 'firebase'])
        .constant('FIREBASE_URL', 'https://weatherapp-9a183.firebaseio.com');

   app.controller('registerController',
        ['$scope', '$firebaseObject', 'FIREBASE_URL', function ($scope, $firebaseAuth, FIREBASE_URL) {

        var ref = new Firebase(FIREBASE_URL);
        var auth = $firebaseAuth(ref);

        auth.$createUser({
            email: "[email protected]",
            password: "123"
        });

    }]);

Upvotes: 0

Views: 392

Answers (1)

MuruGan
MuruGan

Reputation: 1420

Use latest version of firebase and angularfire.

  1. Firebase latest version: 3.6.6
  2. Angualrfire latest version 2.3.0

In order to create a new user with email and password, you should use createUserWithEmailAndPassword method specified in the link. Code like below.

var auth = $firebaseAuth();
auth.$createUserWithEmailAndPassword("[email protected]","123").then(function(){
console.log("Successfully Created") or alert("Successfully Created");
    //Once user is created you can see it in the Authentication (Users) tab.
}).catch(function(err){
console.log(err) or alert(err)
});

I don't know what your trying accomplish here.But to my best knowledge this is the way to create a new user using $firebaseAuth.

Upvotes: 1

Related Questions