POST instantiation for Django-Angular

We currently need to include a CSRF token in our form if we want to POST
to a Django view.  This is cumbersome and should really be a global setting.

Change-Id: I607a0e428833e7478b073eec4d9ef9e1e856ae12
Closes-Bug: #1395270
This commit is contained in:
Thai Tran 2014-12-05 13:58:48 -08:00
parent 3ebc7ae825
commit 04ce53bcb3

View File

@ -9,8 +9,9 @@ var horizonApp = angular.module('hz', dependencies)
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
}])
.run(['hzConfig', 'hzUtils', '$cookieStore',
function (hzConfig, hzUtils, $cookieStore) {
.run(['hzConfig', 'hzUtils', '$cookieStore', '$http', '$cookies',
function (hzConfig, hzUtils, $cookieStore, $http, $cookies) {
$http.defaults.headers.post['X-CSRFToken'] = $cookies.csrftoken;
//expose the configuration for horizon legacy variable
horizon.conf = hzConfig;
horizon.utils = hzUtils;