use meta tags to pass CSRF token.

This commit is contained in:
Qiang Xue
2013-09-17 21:00:19 -04:00
parent 240b42aa0c
commit 1aa836ffc7
3 changed files with 21 additions and 21 deletions

View File

@@ -43,12 +43,19 @@
*/
yii = (function ($) {
var pub = {
// version of Yii framework
version: '2.0',
// CSRF token name and value. If this is set and a form is created and submitted using JavaScript
// via POST, the CSRF token should be submitted too to pass CSRF validation.
csrfVar: undefined,
csrfToken: undefined,
/**
* @return string|undefined the CSRF variable name. Undefined is returned is CSRF validation is not enabled.
*/
getCsrfVar: function() {
return $('meta[name=csrf-var]').attr('content');
},
/**
* @return string|undefined the CSRF token. Undefined is returned is CSRF validation is not enabled.
*/
getCsrfToken: function() {
return $('meta[name=csrf-token]').attr('content');
},
initModule: function (module) {
if (module.isActive === undefined || module.isActive) {