From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 26A4F1FF0AB for ; Wed, 23 Sep 2026 23:00:50 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C3B51216C4; Wed, 23 Sep 2026 23:00:14 +0200 (CEST) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH manager 4/9] ui: token edit: only submit the expiration date when changed Date: Wed, 23 Sep 2026 22:59:53 +0200 Message-ID: <20260923210000.4031318-5-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260923210000.4031318-1-t.lamprecht@proxmox.com> References: <20260923210000.4031318-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1790197207446 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.711 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 6FJIP5HBRIEA6OVR6E5X4PSSUO2KOOGQ X-Message-ID-Hash: 6FJIP5HBRIEA6OVR6E5X4PSSUO2KOOGQ X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The day-granular date field resubmits the stored expiration date truncated to the start of its day, so any unrelated edit, for example of the comment, silently shortened the stored date by up to a day. Drop the value from the submission if the selected day was not actually changed. Signed-off-by: Thomas Lamprecht --- www/manager6/dc/TokenEdit.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/www/manager6/dc/TokenEdit.js b/www/manager6/dc/TokenEdit.js index fc9f0cc2c..2baeb5b74 100644 --- a/www/manager6/dc/TokenEdit.js +++ b/www/manager6/dc/TokenEdit.js @@ -25,6 +25,21 @@ Ext.define('PVE.dc.TokenEdit', { delete values.userid; delete values.tokenid; + // the day-granular date field resubmits the expiration date truncated to the + // start of its day, drop it if the selected day was not actually changed to + // avoid silently shortening the stored date on unrelated edits + if (!win.isCreate && win.originalExpire !== undefined) { + let sameDay = 0; + if (win.originalExpire) { + let day = new Date(win.originalExpire * 1000); + day.setHours(0, 0, 0, 0); + sameDay = Math.floor(day.getTime() / 1000); + } + if (Number(values.expire) === sameDay) { + delete values.expire; + } + } + win.url += `${uid}/token/${tid}`; return values; }, @@ -91,6 +106,20 @@ Ext.define('PVE.dc.TokenEdit', { }); } }, + + setValues: function (values) { + let me = this; + // remember the stored expiration date to detect a real change on submission; the + // token grid's record carries it as a Date object, the API as epoch seconds + if (!me.isCreate && values.expire !== undefined) { + me.originalExpire = + values.expire instanceof Date + ? Math.floor(values.expire.getTime() / 1000) + : Number(values.expire); + } + me.callParent([values]); + }, + apiCallDone: function (success, response, options) { let res = response.result.data; if (!success || !res.value) { -- 2.47.3