そのため、ユーザーの作成時に user.uid を直接取得できないか、ドキュメントに実装されていないようです。authdata が空として返されるため、以下のコードのチャンクを試してみましたが、役に立ちませんでした。回避策はありますか?
注: Authentication と表示されている場所はどこでも、ユーザーを作成するか、それに応じて createUser() または $authWithPassword を使用してユーザーをログインするための作業コードを返すファクトリです。
$scope.register = function (){
Authentication.register($scope.user)
.then(function(user){
var ref = new Firebase (FIREBASE_URL + 'users');
var firebaseUsers = $firebaseAuth(ref);
ref.$authWithPassword({
email: $scope.user.email,
password: $scope.user.password
})
.then(function(authData){
var userInfo = {
regUser: authData.uid,
date: Firebase.ServerValue.TIMESTAMP,
firstname: $scope.user.firstname,
lastname: $scope.user.lastname,
email: $scope.user.email
}
firebaseUsers.$set(regUser,userInfo);
});
Authentication.login($scope.user);
})
.then(function(user){
$timeout(function(){
$location.path('/meetings');
}, 2000);
})
.catch(function(error){
$scope.message = error.toString();
});
} //register
私はこの応答を見ましたが、angularfireで使用すると適用されないようです
ref.createUser({
email: '...',
password: '...'
}, function(err, user) {
if (!err) {
console.log('User created with id', user.uid);
}
});
angularバージョンで動作する例はありますか?