angularJs + firebase $createUser , new SDK error
angularJs + firebase $createUser , new SDK error
我尝试用angular创建用户
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)
});
}
}]);
,当我调用register()函数时,我得到控制台错误:
Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
我使用angular 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>
firebase SDK 3.
控制器:
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);
}
}]);
然后服务:
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;
}]);
要获取配置值,只需打开你的firebase应用概述:https://console.firebase.google.com/project/your-appName/overview
然后点击"Add Firebase to your web app"
工作好!
相关文章:
- 包括用于facebook评论框的JavaScript SDK
- Google/html5语音识别JavaScript SDK Chrome网络工具包SpeechRecognition
- 在流星上使用微信js-sdk时出现拒绝权限错误
- 使用:new Image()控制加载html.src=html_URL
- 如何在corona sdk中从CK编辑器中检索数据
- Soundcloud Javascript SDK 3.0-回调无法读取属性'connectCallback
- FB.login访问令牌facebook javascript SDK
- NativeScript nativeescapet谷歌地图sdk不令人惊叹
- Adobe Air SDK在页面加载时调整窗口大小
- 如何在不使用 new 关键字的情况下从函数创建对象
- 为什么要做新的.Date()与new相差1小时.日期().到ISOString()
- “createImageData()”和“new ImageData(()”有何不同
- Loopback AngularJS JavaScript SDK - Gruntfile plugin
- 插件SDK中的动态或计算对象创建
- 通过sdk/system/events在修改请求观测器上测试http
- 返回值+new Date()与Date.now()是否不同
- 如果设置了cookie,则Facebook登录Javascript SDK自动登录
- Rally SDK外部开发Rally环境未定义
- '范围.分离'注入环回角度sdk时出错
- angularJs + firebase $createUser , new SDK error