ユーザー名と画像を表示するプロファイルページを作成したいとします。 しかし、今のところ私はUsernameに苦労しています。AngularJS - firebaseとGoogleAuthを使用したユーザー名と画像の表示
ユーザー名と画像を表示するプロフィールページですが、現在のユーザー名はgoogAuthです。
これを行う方法を知っている人はいますか?
$scope.login = function()
{
var ref = new Firebase("https://fire.firebaseio.com");
var authData = ref.getAuth();
var userId = authData.uid;
var name = authData[authData.provider].displayName;
ref.authWithOAuthPopup("google", function(error, authData)
{
$timeout(function() {
$scope.username = name;
$scope.userid = userId;
console.log($scope.username);
console.log($scope.userid);
});
if (error)
{
console.log("Login Failed!", error);
}
else
{
$state.go('tabsController.pendingTasks');
ref.child("users").child(authData.uid).once("value",function(snapshot)
{
var ifExists = snapshot.exists();
if(ifExists)
{
console.log("user already exists");
}
else
{
ref.child("users").child(authData.uid).push({id:userId,name:name
}
);
}
});
}
},
{remember: "sessionOnly",
scope: "email"});
}
})
ユーザー名が私のイオンビューに表示されないため、これは動作していないようです。 HTML部分は以下の通りです。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js</script>
<ion-view title="Reminders" id="page7">
<ion-content padding="true" ng-controller="loginCtrl" class="hasheader">
<div class="list card">
<div class="item item-divider">{{username}}</span></div>
<div class="item item-body">
<form class="list">
<ion-checkbox>{{username}}</ion-checkbox>
</form>
</div>
</div>
</ion-content>
</ion-view>
ありがとうございます!
これが正しいとすれば、アカウントを作成するとすぐにユーザーのプロファイルを作成したいのですか? –
はfirebaseのセキュリティとルールにより、私のアプリプロフィールでこの情報を公開することができないのですか? –