我想創建一個顯示用戶名和圖片的個人資料頁面。 但現在我一直在用用戶名掙扎。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安全性和規則可以阻止我在我的應用配置文件中公開這些信息嗎? –