1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Enable create group repo

This commit is contained in:
zhengxie
2015-01-27 17:32:31 +08:00
committed by Daniel Pan
parent 5aab457e95
commit 7920f11b41
8 changed files with 121 additions and 100 deletions

View File

@@ -130,6 +130,29 @@ define([
}
},
prepareApiCsrf: function() {
/* alias away the sync method */
Backbone._sync = Backbone.sync;
/* define a new sync method */
Backbone.sync = function(method, model, options) {
/* only need a token for non-get requests */
if (method == 'create' || method == 'update' || method == 'delete') {
// CSRF token value is in an embedded meta tag
// var csrfToken = $("meta[name='csrf_token']").attr('content');
var csrfToken = app.pageOptions.csrfToken;
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', csrfToken);
};
}
/* proxy the call to the old sync method */
return Backbone._sync(method, model, options);
};
},
prepareCSRFToken: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;