diff --git a/BTPanel/static/js/public.js b/BTPanel/static/js/public.js index aec736ca..a8e020ec 100644 --- a/BTPanel/static/js/public.js +++ b/BTPanel/static/js/public.js @@ -5,6 +5,23 @@ $(document).ready(function() { }); }); +var my_headers = {}; +var request_token_ele = document.getElementById("request_token_head"); +if (request_token_ele) { + var request_token = request_token_ele.getAttribute('token'); + if (request_token) { + my_headers['x-http-token'] = request_token + } +} +request_token_cookie = getCookie('request_token'); +if (request_token_cookie) { + my_headers['x-cookie-token'] = request_token_cookie +} + +if (my_headers) { + $.ajaxSetup({ headers: my_headers }); +} + function RandomStrPwd(b) { b = b || 32; var c = "AaBbCcDdEeFfGHhiJjKkLMmNnPpRSrTsWtXwYxZyz2345678"; @@ -921,7 +938,11 @@ function GetTaskList(a) { } function GetTaskCount() { - $.post("/ajax?action=GetTaskCount", "", function(a) { + $.post("/ajax?action=GetTaskCount", "", function (a) { + if (a.status === false) { + window.location.href = '/login?dologin=True'; + return; + } $(".task").text(a) }) } diff --git a/BTPanel/templates/default/layout.html b/BTPanel/templates/default/layout.html index f8743952..3644c515 100644 --- a/BTPanel/templates/default/layout.html +++ b/BTPanel/templates/default/layout.html @@ -34,6 +34,7 @@
{{session['top_tips']}}
+