[pve-devel] [PATCH manager] ui: dc/TokenEdit: fix editing existing tokens

Dominik Csapak d.csapak at proxmox.com
Fri Feb 12 16:01:15 CET 2021


we always have to calculate the url correctly, not only on creation
otherwise we try to edit the token by doing a 'PUT' request on
/access/users
and not on
/access/users/USERID/token/TOKENID

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/dc/TokenEdit.js | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/www/manager6/dc/TokenEdit.js b/www/manager6/dc/TokenEdit.js
index 3edf18cc..7039249c 100644
--- a/www/manager6/dc/TokenEdit.js
+++ b/www/manager6/dc/TokenEdit.js
@@ -21,14 +21,12 @@ Ext.define('PVE.dc.TokenEdit', {
 	    let me = this;
 	    let win = me.up('pveDcTokenEdit');
 	    win.url = '/api2/extjs/access/users/';
-	    if (win.isCreate) {
-		let uid = encodeURIComponent(values.userid);
-		let tid = encodeURIComponent(values.tokenid);
-		delete values.userid;
-		delete values.tokenid;
+	    let uid = encodeURIComponent(values.userid);
+	    let tid = encodeURIComponent(values.tokenid);
+	    delete values.userid;
+	    delete values.tokenid;
 
-		win.url += `${uid}/token/${tid}`;
-	    }
+	    win.url += `${uid}/token/${tid}`;
 	    return values;
 	},
 	column1: [
@@ -36,8 +34,8 @@ Ext.define('PVE.dc.TokenEdit', {
 		xtype: 'pmxDisplayEditField',
 		cbind: {
 		    editable: (get) => get('isCreate') && !get('fixedUser'),
-		    submitValue: (get) => get('isCreate') || get('fixedUser'),
 		},
+		submitValue: true,
 		editConfig: {
 		    xtype: 'pveUserSelector',
 		    allowBlank: false,
@@ -54,6 +52,7 @@ Ext.define('PVE.dc.TokenEdit', {
 		},
 		name: 'tokenid',
 		fieldLabel: gettext('Token ID'),
+		submitValue: true,
 		minLength: 2,
 		allowBlank: false,
 	    },
-- 
2.20.1






More information about the pve-devel mailing list