I have 2 issues using http-auth-interceptor. Let talk about the first one.
When the API return 401 (for the first time), the application is catching the event event:auth-loginRequired
within a directive present in the index.html and display the modal so the user can login. Then on authentication success, the login script is calling authService.loginConfirmed(user, httpConfigCallback())
. In the callback I'm setting 2 HTTP headers in order to update the API token. The problem is that I cannot see the header set when the initial request is dequeued. Here is my code:
$scope.user = UserAuthService.getUser();
// User is now auth, we confirm it
authService.loginConfirmed($scope.user, function(config){
config.headers["API_USER"] = $scope.user.guid;
config.headers['API_TOKEN'] = $scope.user.api_token;
return config;
});
But the header is not set:
It's working well. The request header screenshot was the one from the OPTIONS
request. It was denied by my server because I did not allowed my additional headers. I've added this:
$response->headers->set('Access-Control-Allow-Headers', "Origin,X-Requested-With,Content-Type,Accept,API_USER,API_TOKEN");
Now everything is working well. Thanks