得到user.uid隨着火力地堡1.0.21和$ firebaseSimpleLogin - 註冊用戶 - 我做了這樣的事情:升級到1.1火力地堡:不能從的createUser()
app.controller('AuthCtrl', function ($scope, $firebase, $firebaseSimpleLogin) {
var ref = new Firebase(MY_FIREBASE_URL);
var auth = $firebaseSimpleLogin(ref);
$scope.register = function (valid) {
// user contains email ad password fields, from my view
auth.$createUser($scope.user.email, $scope.user.password).then(function (auth) {
// auth.user.uid is defined, here; for example: 'simplelogin:13'
// ...
});
};
};
隨着火力地堡1.1, $ firebaseSimpleLogin已被棄用,並且它的功能集成在Firebase核心中。
所以我 - 信任我:-) - 改變了這樣的代碼:
app.controller('AuthCtrl', function ($scope, $firebase) {
var ref = new Firebase(MY_FIREBASE_URL);
var auth = $firebase(ref);
$scope.register = function (valid) {
// user contains email ad password fields, from my view
auth.$createUser($scope.user.email, $scope.user.password).then(function (auth) {
// ...
});
};
};
雖然,我得到$的createUser()爲 '未定義' ...
所以我也嘗試:
app.controller('AuthCtrl', function ($scope, $firebase) {
var ref = new Firebase(MY_FIREBASE_URL);
var auth = $firebase(ref);
$scope.register = function (valid) {
// user contains email ad password fields, from my view
ref.createUser({
email: $scope.user.email,
password: $scope.user.password
}, function(err) {
if (!err) {
// ??? how do I access uid from here ???
}
});
};
};
我確實希望ref.createUser()應該返回一個promise,比如auth。$ createUser做的,但事實並非如此。
所以,我不知道熱讓我的新鮮用戶的UID,將其插入到我的用戶擴展信息的對象數組...
這是怎麼回事的問題(或答案來)從以前的一個不同:HTTP://計算器。 com/questions/26390027/firebase-authwithoauthredirect-woes? – 2014-10-20 20:04:09
弗蘭克,這是非常不同的...與前一個我問如何使用*認證*方法('authWithOAuthRedirect')沒有成功的回調('onAuth()'是答案)。現在我問如何使用'createUser'功能...有沒有'onUserCreated()'方法? :-) – MarcoS 2014-10-21 07:27:04
好的,這是新用戶註冊時的情況嗎?我應該已經意識到,基於'$ scope.register'。 :-) – 2014-10-21 10:59:13