[UPdate] 修改cookie设置

This commit is contained in:
ibuler 2018-01-02 17:02:03 +08:00
parent 6d15f60c5c
commit 68ccec6b9c
3 changed files with 19 additions and 3 deletions

View File

@ -235,6 +235,7 @@ class AdHoc(models.Model):
return result.results_raw, result.results_summary return result.results_raw, result.results_summary
except AnsibleError as e: except AnsibleError as e:
logger.error("Failed run adhoc {}, {}".format(self.task.name, e)) logger.error("Failed run adhoc {}, {}".format(self.task.name, e))
pass
@become.setter @become.setter
def become(self, item): def become(self, item):

View File

@ -357,5 +357,16 @@ String.prototype.format = function(args) {
function setCookie(key, value) { function setCookie(key, value) {
var expires = new Date(); var expires = new Date();
expires.setTime(expires.getTime() + (24 * 60 * 60 * 1000)); 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=/';
}
} }

View File

@ -37,15 +37,19 @@
$(document).ready(function () { $(document).ready(function () {
}) })
.on('click', '#switch_admin', function () { .on('click', '#switch_admin', function () {
var cookieName = "IN_ADMIN_PAGE";
setTimeout(function () { setTimeout(function () {
setCookie("IN_ADMIN_PAGE", "Yes"); delCookie(cookieName);
setCookie(cookieName, "Yes");
window.location = "/" window.location = "/"
}, 100) }, 100)
}) })
.on('click', '#switch_user', function () { .on('click', '#switch_user', function () {
var cookieName = "IN_ADMIN_PAGE";
setTimeout(function () { setTimeout(function () {
console.log("Set to No"); console.log("Set to No");
setCookie("IN_ADMIN_PAGE", "No"); delCookie(cookieName);
setCookie(cookieName, "No");
window.location = "/" window.location = "/"
}, 100); }, 100);
}) })