2016-08-08 7 views
0

ich versuche, Benutzer zu erstellen, mit Winkel

myApp.controller('loginCtrl',['$scope','$firebaseAuth','config',function($scope,$firebaseAuth,config){ 

console.info('[APP-INFO] ~ loginCtrl Start') 

var ref = new Firebase('https://myauth-tadmit.firebaseio.com/'); 
var auth = $firebaseAuth(ref); 

$scope.register = function(){  
    auth.$createUser({ 
     email: $scope.user.email, 
     password: $scope.user.password 
    }).then(function(regUser){ 
     console.log('RegComplete User:') 
    }).catch(function(error){ 
     console.log(error.message) 
    }); 
} 

}]); 

und wenn i-Register() Funktion aufrufen, erhalte ich i erorr trösten:

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/ 

i Verwenden Sie Winkel 1.5.8 +

<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script> 
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script> 

was mache ich falsch ?!

+0

Sie verwenden ein 2.x SDK, um eine Verbindung zu einer 3.x-Firebase herzustellen. Sehen Sie sich das [Upgrade-Handbuch] (https://firebase.google.com/support/guides/firebase-web) an. –

Antwort

0

Feuerbasis sdk 3.

Controller:

myApp.controller('loginCtrl',['$scope','FbAuthService',function($scope,FbAuthService){ 

console.info('[APP-INFO] ~ loginCtrl Start') 

$scope.register = function(email,password,info){ 

    FbAuthService.register(email,password,info); 
} 


}]); 

dann Service:

myApp.service('FbAuthService',['$firebaseAuth','$location',function($firebaseAuth,$location){ 

var config = { 
    apiKey: "", 
    authDomain: "", 
    databaseURL: "", 
    storageBucket: "", 
}; 

firebase.initializeApp(config); 


// Authentication 
var authObj = $firebaseAuth(); 
var self = {}; 

self.register = function(email,password,info){ 
    authObj.$createUserWithEmailAndPassword(
     email, 
     password 
    ).then(function(newUser){ 

     //add Info from Signup to USERS => newUser.id => info(Object) 
     var ref = firebase.database().ref().child('users').child(newUser.uid); 
     ref.set({ firstname: info.firstname, lastname: info.lastname, uid: newUser.uid }); 
     $location.path('/login') 
    }).catch(function(error){ 
     console.log(error.message) 
    }); 
} 

return self; 
}]); 

Um Konfigurationswert zu erhalten, öffnen Sie einfach Ihre Feuerbasis App im Überblick: https://console.firebase.google.com/project/your-appName/overview

dann Klicken Sie auf "Firebase hinzufügen zu Ihrem w eb app "

funktionieren gut!