mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-05-28 14:46:11 +00:00
fix #3887: ui: add regenerate token button
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
This commit is contained in:
parent
f41a233a8e
commit
713fa6ee55
@ -100,6 +100,25 @@ Ext.define('PBS.config.TokenView', {
|
||||
}).show();
|
||||
},
|
||||
|
||||
regenerateToken: function(_button, _event, record) {
|
||||
let tokenid = record.data.tokenid;
|
||||
let user = PBS.Utils.extractTokenUser(tokenid);
|
||||
let tokenname = PBS.Utils.extractTokenName(tokenid);
|
||||
Proxmox.Utils.API2Request({
|
||||
method: 'PUT',
|
||||
url: `/access/users/${user}/token/${tokenname}`,
|
||||
params: { 'regenerate': true },
|
||||
success: function(res, opt) {
|
||||
Ext.create("PBS.window.TokenShow", {
|
||||
autoShow: true,
|
||||
tokenid: tokenid,
|
||||
secret: res.result.data.secret,
|
||||
});
|
||||
},
|
||||
failure: res => Ext.Msg.alert(gettext("Error"), res.htmlStatus),
|
||||
});
|
||||
},
|
||||
|
||||
showPermissions: function() {
|
||||
let me = this;
|
||||
let view = me.getView();
|
||||
@ -174,6 +193,16 @@ Ext.define('PBS.config.TokenView', {
|
||||
handler: 'showPermissions',
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
xtype: 'proxmoxButton',
|
||||
text: gettext('Regenerate'),
|
||||
handler: 'regenerateToken',
|
||||
dangerous: true,
|
||||
confirmMsg: rec => Ext.String.format(
|
||||
gettext("Regenerate the secret of the API token '{0}'? All current use-sites will loose access!"),
|
||||
rec.data.tokenid,
|
||||
),
|
||||
},
|
||||
],
|
||||
|
||||
viewConfig: {
|
||||
|
Loading…
Reference in New Issue
Block a user