1

我有一个控制器来处理我的 Angular 应用程序的身份验证。

'use strict';

/**
  * Controller used for authentications
  */

angular.module('myAPP').controller('SignInUpController', function ($scope, $location, $auth) {
    $scope.testVariable = 'Testa;dffdjklkjlakl;dklskf';

    $scope.message = 'FAILED';

    $scope.authenticate = function(provider) {
     $auth.authenticate(provider).then(function() {
       $location.path('/signinup');
       $scope.message = 'SUCCESS';
     }).catch(function(response) {
       $scope.message = response.data.message;
     });
    };

});

在这个时间点,我只是想让登录功能正常工作。它似乎工作。我的 HTML 上有一个按钮可以触发此操作。它工作正常。将出现一个 Facebook 弹出窗口,并请求许可。问题发生在返回。我收到以下错误。

angular.js:10661 POST http://localhost:9000/auth/facebook 404 (Not Found
(anonymous function) @ angular.js:10661
sendReq @ angular.js:10480
serverRequest @ angular.js:10187
processQueue @ angular.js:14634
(anonymous function) @ angular.js:14650
Scope.$eval @ angular.js:15878
Scope.$digest @ angular.js:15689
Scope.$apply @ angular.js:15986
tick @ angular.js:11231

我所有的卫星发射器配置都是默认的。

facebook: {
          name: 'facebook',
          url: '/auth/facebook',
          authorizationEndpoint: 'https://www.facebook.com/v2.3/dialog/oauth',
          redirectUri: (window.location.origin || window.location.protocol + '//' + window.location.host) + '/',
          requiredUrlParams: ['display', 'scope'],
          scope: ['email'],
          scopeDelimiter: ',',
          display: 'popup',
          type: '2.0',
          popupOptions: { width: 580, height: 400 }
 }

从这段代码看来,它应该被击中。但我不确定为什么它不起作用。

这和ui-router有什么关系吗?我在想也许这与它为什么不起作用有关。

一般来说,我是 Satellizer 的新手。如果我把一个简单的问题复杂化了,请提前道歉。

4

1 回答 1

0

您必须实现一个服务器端组件来处理/auth/facebookPOST 端点并返回一个有效的 JWT。

satellizer 项目的示例目录中有实现此功能的示例。

于 2015-09-03T19:19:01.613 回答