mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Automatically retry AJAX request with new CSRF token if token error is returned
다른 탭에서 로그아웃했다가 다시 로그인한 후 exec_json을 시도하는 등, 사용자가 보기에는 정상적인 상황인데도 보안정책(CSRF) 오류가 발생할 수 있음. 이 때 자연스럽게 토큰을 갱신한 후 요청을 다시 전송하도록 개선함.
This commit is contained in:
parent
ed649fb58c
commit
de7bf0a0a6
2 changed files with 21 additions and 5 deletions
|
|
@ -53,12 +53,19 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* @brief Get CSRF token for the document
|
||||
* Get CSRF token for the document
|
||||
*/
|
||||
window.getCSRFToken = function() {
|
||||
return $("meta[name='csrf-token']").attr("content");
|
||||
};
|
||||
|
||||
/**
|
||||
* Set CSRF token for the document
|
||||
*/
|
||||
window.setCSRFToken = function(token) {
|
||||
$("meta[name='csrf-token']").attr("content", token);
|
||||
};
|
||||
|
||||
/* Intercept jQuery AJAX calls to add CSRF headers */
|
||||
$.ajaxPrefilter(function(options) {
|
||||
if (!isSameOrigin(location.href, options.url)) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue