From 35a04562fd09a30972d9e1fa3b1ea749603b2e25 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 25 Jan 2018 14:36:51 +0100 Subject: [PATCH] change PVE.UserName/CSRFPreventionToken to Proxmox this is now all in the widget-toolkit and needs to be set/read to/from there, else we possibly get an inconsistent view on those this fixes as issue, where after login the ResourceStore would not update Signed-off-by: Dominik Csapak Reviewed-by: Thomas Lamprecht Tested-by: Thomas Lamprecht --- www/index.html.tpl | 2 -- www/manager6/Utils.js | 9 --------- www/manager6/Workspace.js | 14 +++++++------- www/manager6/lxc/Resources.js | 2 +- www/manager6/node/Config.js | 2 +- www/mobile/Workspace.js | 6 +++--- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/www/index.html.tpl b/www/index.html.tpl index 147d3492..a972e3aa 100644 --- a/www/index.html.tpl +++ b/www/index.html.tpl @@ -36,8 +36,6 @@ diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index 1d67238e..8f80c76a 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -20,15 +20,6 @@ Ext.Ajax.defaultHeaders = { 'Accept': 'application/json' }; -Ext.Ajax.on('beforerequest', function(conn, options) { - if (PVE.CSRFPreventionToken) { - if (!options.headers) { - options.headers = {}; - } - options.headers.CSRFPreventionToken = PVE.CSRFPreventionToken; - } -}); - Ext.define('PVE.Utils', { utilities: { // this singleton contains miscellaneous utilities diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js index 8d6bb4d1..c7b88761 100644 --- a/www/manager6/Workspace.js +++ b/www/manager6/Workspace.js @@ -19,8 +19,8 @@ Ext.define('PVE.Workspace', { updateLoginData: function(loginData) { var me = this; me.loginData = loginData; - PVE.CSRFPreventionToken = loginData.CSRFPreventionToken; - PVE.UserName = loginData.username; + Proxmox.CSRFPreventionToken = loginData.CSRFPreventionToken; + Proxmox.UserName = loginData.username; if (loginData.cap) { Ext.state.Manager.set('GuiCap', loginData.cap); @@ -37,7 +37,7 @@ Ext.define('PVE.Workspace', { var me = this; Proxmox.Utils.authClear(); - PVE.UserName = null; + Proxmox.UserName = null; me.loginData = null; if (!me.login) { @@ -78,13 +78,13 @@ Ext.define('PVE.Workspace', { Ext.TaskManager.start({ run: function() { var ticket = Proxmox.Utils.authOK(); - if (!ticket || !PVE.UserName) { + if (!ticket || !Proxmox.UserName) { return; } Ext.Ajax.request({ params: { - username: PVE.UserName, + username: Proxmox.UserName, password: ticket }, url: '/api2/json/access/ticket', @@ -164,8 +164,8 @@ Ext.define('PVE.StdWorkspace', { var ui = me.query('#userinfo')[0]; - if (PVE.UserName) { - var msg = Ext.String.format(gettext("You are logged in as {0}"), "'" + PVE.UserName + "'"); + if (Proxmox.UserName) { + var msg = Ext.String.format(gettext("You are logged in as {0}"), "'" + Proxmox.UserName + "'"); ui.update('
' + msg + '
'); } else { ui.update(''); diff --git a/www/manager6/lxc/Resources.js b/www/manager6/lxc/Resources.js index 55514cdd..58482779 100644 --- a/www/manager6/lxc/Resources.js +++ b/www/manager6/lxc/Resources.js @@ -197,7 +197,7 @@ Ext.define('PVE.lxc.RessourceView', { var isDisk = (rowdef.tdCls == 'pve-itype-icon-storage'); var noedit = rec.data['delete'] || !rowdef.editor; - if (!noedit && PVE.UserName !== 'root@pam' && key.match(/^mp\d+$/)) { + if (!noedit && Proxmox.UserName !== 'root@pam' && key.match(/^mp\d+$/)) { var mp = PVE.Parser.parseLxcMountPoint(value); if (mp.type !== 'volume') { noedit = true; diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 006d921c..bbda9842 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -217,7 +217,7 @@ Ext.define('PVE.node.Config', { xtype: 'proxmoxNodeAPT', upgradeBtn: { xtype: 'pveConsoleButton', - disabled: PVE.UserName !== 'root@pam', + disabled: Proxmox.UserName !== 'root@pam', text: gettext('Upgrade'), consoleType: 'upgrade', nodename: nodename diff --git a/www/mobile/Workspace.js b/www/mobile/Workspace.js index f608ced6..765fb6d2 100644 --- a/www/mobile/Workspace.js +++ b/www/mobile/Workspace.js @@ -107,8 +107,8 @@ Ext.define('PVE.Workspace', { statics: { updateLoginData: function(loginData) { PVE.Workspace.loginData = loginData; - PVE.CSRFPreventionToken = loginData.CSRFPreventionToken; - PVE.UserName = loginData.username; + Proxmox.CSRFPreventionToken = loginData.CSRFPreventionToken; + Proxmox.UserName = loginData.username; // creates a session cookie (expire = null) // that way the cookie gets deleted after browser window close @@ -119,7 +119,7 @@ Ext.define('PVE.Workspace', { statics: { showLogin: function() { Proxmox.Utils.authClear(); - PVE.UserName = null; + Proxmox.UserName = null; PVE.Workspace.loginData = null; PVE.Workspace.gotoPage(''); -- 2.39.2