- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我按照 official tutorial 设置了一个简单的 Firebase Facebook OAuth 登录设置,如下所示用于 Ionic Firebase Facebook 登录。
问题是,一旦我用 Facebook 按钮点击登录,我就会被重定向到 Facebook,我登录,然后我被重定向回我的应用程序。但是,问题是我停留在登录页面。奇怪的是,如果我通过按 F5 物理刷新我的浏览器(使用 ionic serve
测试) onAuth
触发器,我被重定向到 Items
页。如果我不刷新浏览器,onAuth
不会被调用。
有人有这个问题吗?你是怎么解决的?
请注意,是的,我做了我的研究(并且有点开始失去它),但无法让它工作。我搜索了SO,尝试使用$timeout从谷歌组,试图调用 $scope.$apply(),但都无济于事 - 所以请帮我找出我做错了什么?
.controller('AppCtrl', function($scope, Items, Auth, $state, $ionicHistory) {
$scope.login = function(provider) {
Auth.$authWithOAuthRedirect(provider).then(function(authData) {
}).catch(function(error) {
if (error.code === "TRANSPORT_UNAVAILABLE") {
Auth.$authWithOAuthPopup(provider).then(function(authData) {
});
} else {
console.log(error);
}
});
};
$scope.logout = function() {
Auth.$unauth();
$scope.authData = null;
$window.location.reload(true);
};
Auth.$onAuth(function(authData) {
if (authData === null) {
console.log("Not logged in yet");
$state.go('app.login');
} else {
console.log("Logged in as", authData.uid);
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('app.items');
}
$scope.authData = authData; // This will display the user's name in our view
});
})
<ion-view view-title="Members area">
<ion-content padding="true">
<div ng-if="!authData">
<button class="button button-positive button-block" ng-click="login('facebook')">Log In with Facebook</button>
</div>
<div ng-if="authData.facebook">
<div class="card">
<div class="item item-text-wrap">Hello {{authData.facebook.displayName}}!</div>
</div>
<button class="button button-assertive button-block" ng-click="logout()">Log out</button>
</div>
</ion-content>
</ion-view>
$timeout(function(){
Auth.$onAuth(function(authData) {
if (authData === null) {
console.log("Not logged in yet");
$state.go('app.login');
} else {
console.log("Logged in as", authData.uid);
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('app.items');
}
$scope.authData = authData; // This will display the user's name in our view
});
}, 3000);
最佳答案
发布在 github 问题上,但也会在这里回复。
这只发生在使用 $authWithOAuthRedirect
的浏览器中.该示例适用于cordova 应用程序,因此这真的不应该成为问题。
但是如果你真的需要它,你可以跳过重定向并使用弹出窗口。
Auth.$authWithOAuthPopup(authMethod).then(function(authData) {
console.dir(authData);
});
关于angularjs - Firebase $authWithOAuthRedirect 不会在没有页面刷新的情况下调用 $onAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31872935/
在我的单页应用程序中,当用户单击“注销”按钮时,我会调用 firebase.unauth()。这会导致 firebase 客户端取消身份验证(这并不奇怪),我得到了 firebase.onAuth(c
我按照 official tutorial 设置了一个简单的 Firebase Facebook OAuth 登录设置,如下所示用于 Ionic Firebase Facebook 登录。 问题是,一
我使用 Firebase 作为我的主要后端解决方案,并创建了一个服务来处理整个应用程序中的身份验证(自从我开始使用 simpleLogin 现在我正在尝试使用他们内置的登录方法,我认为它可能在从应用程
我是一名优秀的程序员,十分优秀!