[pve-devel] [PATCH manager v1 1/1] fix #4546: ui: notify user if their user account expires soon

Philipp Hufnagl p.hufnagl at proxmox.com
Fri Sep 22 16:36:55 CEST 2023


When the user account that is currently logged in will expire soon, the
user icon will turn into a yellow exclamation mark. In the user menu
there will be a new element informing the user briefly about it. If the
element is clicked, a popup will appear informing the user in detail
about it

Signed-off-by: Philipp Hufnagl <p.hufnagl at proxmox.com>
---
 www/manager6/Workspace.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index 18d574b7..9d166493 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -42,6 +42,7 @@ Ext.define('PVE.Workspace', {
 	Proxmox.Utils.authClear();
 	Ext.state.Manager.clear('GuiCap');
 	Proxmox.UserName = null;
+	Proxmox.UserExpires = null;
 	me.loginData = null;
 
 	if (!me.login) {
@@ -198,6 +199,18 @@ Ext.define('PVE.StdWorkspace', {
 	let me = this;
 	let ui = me.query('#userinfo')[0];
 	ui.setText(Ext.String.htmlEncode(Proxmox.UserName || ''));
+	let label = me.query('#expirewarning')[0];
+	if (Proxmox.UserExpires !== null) {
+	    let expieWariningThreshold = Ext.Date.add(new Date(), Ext.Date.DAY, 7);
+	    let expireDate = new Date(Proxmox.UserExpires * 1000);
+	    if (expieWariningThreshold >= expireDate) {
+	        ui.setIconCls('fa fa-exclamation-triangle warning');
+		label.setHidden(false);
+	    }
+	} else {
+		label.setHidden(true);
+		ui.setIconCls('fa fa-user');
+	}
 	ui.updateLayout();
     },
 
@@ -367,6 +380,21 @@ Ext.define('PVE.StdWorkspace', {
 			    },
 			    iconCls: 'fa fa-user',
 			    menu: [
+				{
+				    iconCls: 'fa fa-exclamation-triangle warning',
+				    itemId: 'expirewarning',
+				    text: gettext('Account expiring soon!'),
+				    hidden: true,
+				    handler: function() {
+					let expireDate = new Date(Proxmox.UserExpires * 1000);
+					Ext.Msg.show({
+					    title: gettext('Account expiring soon!'),
+					    icon: Ext.Msg.WARNING,
+					    message: Ext.String.format(gettext("Your account is expiring on {0} . After that you won't be able to log in!"), expireDate),
+					    buttons: Ext.Msg.OK,
+					});
+				    },
+				},
 				{
 				    iconCls: 'fa fa-gear',
 				    text: gettext('My Settings'),
-- 
2.39.2






More information about the pve-devel mailing list