]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
change PVE.UserName/CSRFPreventionToken to Proxmox
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 25 Jan 2018 13:36:51 +0000 (14:36 +0100)
committerDominik Csapak <d.csapak@proxmox.com>
Thu, 25 Jan 2018 13:49:11 +0000 (14:49 +0100)
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 <d.csapak@proxmox.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/index.html.tpl
www/manager6/Utils.js
www/manager6/Workspace.js
www/manager6/lxc/Resources.js
www/manager6/node/Config.js
www/mobile/Workspace.js
www/touch/index.html.tpl

index 147d349217b41eb2e268db9d57b9b7587d405c14..a972e3aa49de95364a1ad8ced8568ec28101b5e9 100644 (file)
@@ -36,8 +36,6 @@
 
     <script type="text/javascript">
     if (typeof(PVE) === 'undefined') PVE = {};
-    PVE.UserName = '[% username %]'
-    PVE.CSRFPreventionToken = '[% token %]';
     Ext.History.fieldid = 'x-history-field';
     Ext.onReady(function() { Ext.create('PVE.StdWorkspace');});
     </script>
index 1d67238e1d9c2ffd3bf4b50a5917d0f0985861c0..8f80c76ae47d042d8f7d32bb44b268465cab18fc 100644 (file)
@@ -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
index 8d6bb4d11c9abc048accb9c0298428284a30e915..c7b887613249ac37920687a4158d0b3832b5aa3f 100644 (file)
@@ -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('<div class="x-unselectable" style="white-space:nowrap;">' + msg + '</div>');
        } else {
            ui.update('');
index 55514cdd92c4db8c406edd1a8d0a479a8e85284d..58482779c00f81e0d46835e5918cefd9be216803 100644 (file)
@@ -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;
index 006d921c159462111b9c0188adb961a99805fd16..bbda984201485a93401dddd4dc08d5150699b744 100644 (file)
@@ -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
index f608ced68868d515401b2ffcb15d87e84a5bab9c..765fb6d22c8c42649ba081b3e57232e637092c4e 100644 (file)
@@ -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('');
index f5787b6d9640c32a5ff802dca01ed20c3c87d295..33188fbc08299a979a0d231c5e60a3b44113c77a 100644 (file)
@@ -25,8 +25,6 @@
     <script type="text/javascript" src="/pve2/touch/pvemanager-mobile.js?ver=[% version %]"></script>
     <script type="text/javascript">
 if (typeof(PVE) === 'undefined') PVE = {};
-PVE.UserName = '[% username %]'
-PVE.CSRFPreventionToken = '[% token %]';
     </script>
   </head>
   <body>