Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(auth): Cookies now on all API requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Schranz committed Mar 20, 2015
1 parent 92d3ca0 commit 5b0228d
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions app/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ function appConfig($urlRouterProvider: ng.ui.IUrlRouterProvider,
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise("/projects");
RestangularProvider.setBaseUrl(config.api);
RestangularProvider.setDefaultHttpFields({cache: true});
RestangularProvider.setDefaultHttpFields({
cache: true,
withCredentials: true
});
}

/* @ngInject */
Expand All @@ -55,22 +58,6 @@ function appRun(gettextCatalog: any, Restangular: restangular.IProvider,
// TODO more than just 404
//$state.go("404", {}, {inherit: true});
});

Restangular.setFullRequestInterceptor(function(element, operation, route, url, headers, params, httpConfig) {
var userHeaders = {};

if (UserService.currentUser || $cookies["X-Auth-Token"]) {
userHeaders["X-Auth-Token"] = $cookies["X-Auth-Token"];
userHeaders["X-Auth-Username"] = $cookies["X-Auth-Username"];
}

return {
element: element,
params: params,
headers: _.extend(headers, userHeaders),
httpConfig: httpConfig
};
});
Restangular.addResponseInterceptor((data, operation: string, model: string, url, response, deferred) => {
// Ajax
CoreService.xhrDone();
Expand Down

0 comments on commit 5b0228d

Please sign in to comment.