mirror of https://github.com/jumpserver/jumpserver
[UPdate] 修改cookie设置
parent
6d15f60c5c
commit
68ccec6b9c
|
@ -235,6 +235,7 @@ class AdHoc(models.Model):
|
|||
return result.results_raw, result.results_summary
|
||||
except AnsibleError as e:
|
||||
logger.error("Failed run adhoc {}, {}".format(self.task.name, e))
|
||||
pass
|
||||
|
||||
@become.setter
|
||||
def become(self, item):
|
||||
|
|
|
@ -357,5 +357,16 @@ String.prototype.format = function(args) {
|
|||
function setCookie(key, value) {
|
||||
var expires = new Date();
|
||||
expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000));
|
||||
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
|
||||
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString() + ';path=/';
|
||||
console.log("Cookie: " + document.cookie)
|
||||
}
|
||||
|
||||
|
||||
function delCookie(key) {
|
||||
var expires = new Date();
|
||||
expires.setTime(expires.getTime() - 1);
|
||||
var val = getCookie(key);
|
||||
if (val !== null) {
|
||||
document.cookie = key + '=' + val + ";expires" + expires.toUTCString() + ';path=/';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,15 +37,19 @@
|
|||
$(document).ready(function () {
|
||||
})
|
||||
.on('click', '#switch_admin', function () {
|
||||
var cookieName = "IN_ADMIN_PAGE";
|
||||
setTimeout(function () {
|
||||
setCookie("IN_ADMIN_PAGE", "Yes");
|
||||
delCookie(cookieName);
|
||||
setCookie(cookieName, "Yes");
|
||||
window.location = "/"
|
||||
}, 100)
|
||||
})
|
||||
.on('click', '#switch_user', function () {
|
||||
var cookieName = "IN_ADMIN_PAGE";
|
||||
setTimeout(function () {
|
||||
console.log("Set to No");
|
||||
setCookie("IN_ADMIN_PAGE", "No");
|
||||
delCookie(cookieName);
|
||||
setCookie(cookieName, "No");
|
||||
window.location = "/"
|
||||
}, 100);
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue