0

I'm using AngularJs and I want to create an user in firebase, then I wrote the following code, however it isn't working!

var myApp = angular.module('myApp', ['firebase', 'ngRoute']);
myApp.constant('FIREBASE_URL', 'MY_FIREBASE_URL');
myApp.controller('RegisterController', ['$scope', '$firebaseAuth', 'FIREBASE_URL', function($scope, $firebaseAuth, FIREBASE_URL) {
  $scope.headerTitle = "Registration Form";
  var ref = new Firebase(FIREBASE_URL);
  var auth = $firebaseAuth(ref);

  $scope.register = function() {
        auth.$createUser({
          email: $scope.user.email,
          password: $scope.user.password
        }).then(function(regUser) {
          $scope.message = $scope.user.firstName + " " + $scope.user.lastName + " " + "welcome !";
        }).catch(function(error) {
          $scope.message = error.message;
        });
  }
}]);

I get the following error when submit form : Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

3
  • and i get the following error when submit form : Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/ Commented Jul 3, 2016 at 14:46
  • See stackoverflow.com/questions/38010536/…. You'll need to use version 2.x of AngularFire. Commented Jul 3, 2016 at 15:03
  • i try version 2.0.1 of angularFire but not working and throw following error in the console : ReferenceError: Firebase is not defined Commented Jul 3, 2016 at 19:19

1 Answer 1

1

For Firebase 3.x and AngularFire 2.x you have to Initialize the Firebase SDK by adding the code snippet to your html file.

1) Copy the code snippet

  • Go to your Project Firebase Console https://console.firebase.google.com/project/
  • in the main page of your project, click on Add Firebase to your web app
  • in the popup, copy the code snippet, it may look like this:

    <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script>
    <script>
        // Initialize Firebase
        var config = {
            apiKey: " ** your key ** ",
            authDomain: "your-domain.firebaseapp.com",
            databaseURL: "https://your-domain.firebaseio.com",
            storageBucket: "your-domain.appspot.com",
        };
        firebase.initializeApp(config);
    </script>
    

2) Paste the code snippet in your html file.

  • Paste the snippet at the bottom of your HTML or before other script tags.

have fun!

Sign up to request clarification or add additional context in comments.

5 Comments

i use it but in console show following error : [s31.postimg.org/xxemv39m3/…
Please, can you paste you full html file to get a better picture of what may be the issue?
yes you can see my html code in jsfiddle : jsfiddle.net/pxesghog and soo i use the lasted version of firebase and angularfire
Ok, try pasting the firebase code snippet (as mentioned in point 2) before all the script tags, that is before the script tag <script src="Js/uikit.min.js"></script>
please help me !! :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.