ui: Workspace: use domains info to hide password/tfa items

in the user menu

we have to make an additional api call here, since it is the only
place (currently) where we can get the realm type

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ Thomas: adapt to move of parse_userid to widget-toolkit ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-07-01 14:25:06 +02:00 committed by Thomas Lamprecht
parent b8dcc6d307
commit c5be8d39c9

View File

@ -172,6 +172,23 @@ Ext.define('PVE.StdWorkspace', {
}
},
});
Proxmox.Utils.API2Request({
url: '/access/domains',
method: 'GET',
success: function(response) {
let [_username, realm] = Proxmox.Utils.parse_userid(Proxmox.UserName);
response.result.data.forEach((domain) => {
if (domain.realm === realm) {
let schema = PVE.Utils.authSchema[domain.type];
if (schema) {
me.query('#tfaitem')[0].setHidden(!schema.tfa);
me.query('#passworditem')[0].setHidden(!schema.pwchange);
}
}
});
},
});
}
},
@ -353,6 +370,7 @@ Ext.define('PVE.StdWorkspace', {
},
{
text: gettext('Password'),
itemId: 'passworditem',
iconCls: 'fa fa-fw fa-key',
handler: function() {
var win = Ext.create('Proxmox.window.PasswordEdit', {
@ -363,6 +381,7 @@ Ext.define('PVE.StdWorkspace', {
},
{
text: 'TFA',
itemId: 'tfaitem',
iconCls: 'fa fa-fw fa-lock',
handler: function(btn, event, rec) {
var win = Ext.create('PVE.window.TFAEdit', {