2016-11-06 42 views
1

我一直在試圖遵循this指南讓我的自定義登錄屏幕與我的角度應用程序在本地一起工作。我正在努力的部分是我的登錄回調永遠不會被調用。試圖找出auth0自定義登錄屏幕回調url

我原來的登錄URL是http://localhost:9000/#/login

angular.module('myApp').service('authService', function ($location, angularAuth0) { 

    function login(username, password, callback) { 
     console.log('in login service'); 
    angularAuth0.login({ 
     connection: 'Username-Password-Authentication', 
     responseType: 'token', 
     email: username, 
     password: password 
    }, function(err) { 
     console.log('we NEVER get here'); 
    }); 
    } 

    return { 
     login: login 
    }; 

}); 


angular.module('myApp').controller('LoginCtrl', function ($scope, $location, authService) { 

    $scope.login = function() { 
     ... 
     authService.login($scope.user.email, $scope.user.password) 

當我登錄,我重定向到http://localhost:9000/#/access_token<myaccesstoken>&id_token=<myIdToken>&token_type=Bearer

爲何我會被重定向到這個網址和我的回調永遠不會叫什麼名字?

另外,當我應該使用這個功能authenticateAndGetProfile()他們在指南中創建?

+0

你的auth0.service.js是這樣的:https://github.com/auth0-samples/auth0-angularjs-sample/blob/master/02-Custom-Login/components/auth/auth.service。 JS? 在https://github.com/auth0-samples/auth0-angularjs-sample/tree/master/02-Custom-Login你有一個工作樣本,它是否適合你? –

+0

是的,你可以在authService中看到我的登錄功能是一樣的。我還沒有試過克隆這個樣本並運行它。我注意到的一件事是'authenticateAndGetProfile'方法永遠不會從任何地方被調用。 – Catfish

回答

2

確定與Auth0支持團隊合作,似乎它們的文檔缺少這一部分,其已經添加:

Register the authenticateAndGetProfile in app.run.js so that authentication results get processed after login. 

// app.run.js 

(function() { 

    'use strict'; 

    angular 
    .module('app') 
    .run(function (authService) { 

    // Process the auth token if it exists and fetch the profile 
    authService.authenticateAndGetProfile(); 
    }); 

})(); 

那是失落的一角,現在一切正常。