问题
我正在致力于通过Satellizer实现facebook登录。它在桌面上工作很好,但是当在移动上访问时,它有时工作,有时不工作。当登录弹出不工作时,它永远不会关闭,它在登录弹出窗口中打开主页,而请求登录的主屏幕仍在等待弹出窗口关闭。有什么不对的地方吗?
示例代码
我就是这样从facebook上认证的
var commonConfig = {
popupOptions: {
location: 'no',
toolbar: 'yes',
width: window.screen.width,
height: window.screen.height
}
};
var permissions = ["public_profile","email"];
$authProvider.facebook(angular.extend({}, commonConfig, {
clientId: FacebookAppId,
url: ApiUrl+'api/v1/facebook/auth',
scope:permissions,
scopeDelimiter:','
}));当按下“使用facebook连接”时,将调用此代码
$scope.loginSocial = function () {
$scope.disableSubmitBtn = true;
$scope.showSpinner = true;
$auth.authenticate('facebook')
.then(function (result) {
result = angular.fromJson(result.data.code)
return AuthServerProvider.loginFb(result.facebookCode);
},function (error) {
$scope.status = 'facebook-error';
$scope.disableSubmitBtn = false;
$scope.showSpinner = false;
})
.then(function(){
$scope.disableSubmitBtn = true;
$scope.showSpinner = true;
})这段代码在桌面浏览器上运行得很好,但是当通过手机浏览器访问时,"$auth.authenticate('facebook')“在大多数情况下都会失败。
发布于 2017-01-18 12:13:06
我们在使用Satellizer时也面临着类似的问题。结果发现问题在于如何在角redirectUri内处理ui.router。如果您返回到库文档,您将注意到这个qoute:
为了避免潜在的404错误,请为每个返回200个OK的redirectUri > URL创建服务器路由。或者,您也可以使用加载旋转器呈现自定义模板。目前,由于20 may的间隔轮询,弹出窗口不会保持足够长的时间来查看自定义模板,但在>将来,我可能会添加对重写此轮询间隔值的支持。
在上面提到的代码中,您没有分配redirectUri,因此它将默认为'/‘。如果您已经以不同的方式处理了这个路由,那么它有时可能会被角路径捕获,并在Satellizer能够获取它之前被重定向。为了解决这个问题,只需分配一个redirectUri并通过角路径处理它。
欲知更多详情,请访问读这篇文章。
https://stackoverflow.com/questions/39061086
复制相似问题