mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-10-04 05:09:24 +00:00
fix #6528: tfa: update user config on removal of TFA
When removing TFA from a user via the command line, the change was not reflected in the GUI or in the output of `pveum user list`. Both continued to show that TFA was enabled for the user. Fixed the issue by updating the user configuration file. Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
This commit is contained in:
parent
5baa80c784
commit
1398ef8d0b
@ -141,13 +141,25 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $userid = extract_param($param, "userid");
|
my $userid = extract_param($param, "userid");
|
||||||
my $tfa_id = extract_param($param, "id");
|
my $tfa_id = extract_param($param, "id");
|
||||||
|
my $update_user_config;
|
||||||
|
|
||||||
PVE::AccessControl::lock_tfa_config(sub {
|
PVE::AccessControl::lock_tfa_config(sub {
|
||||||
my $tfa_cfg = cfs_read_file('priv/tfa.cfg');
|
my $tfa_cfg = cfs_read_file('priv/tfa.cfg');
|
||||||
if (defined($tfa_id)) {
|
if (defined($tfa_id)) {
|
||||||
$tfa_cfg->api_delete_tfa($userid, $tfa_id);
|
my $has_entries_left = $tfa_cfg->api_delete_tfa($userid, $tfa_id);
|
||||||
|
$update_user_config = !$has_entries_left;
|
||||||
} else {
|
} else {
|
||||||
$tfa_cfg->remove_user($userid);
|
$tfa_cfg->remove_user($userid);
|
||||||
|
$update_user_config = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($update_user_config) {
|
||||||
|
PVE::AccessControl::lock_user_config(sub {
|
||||||
|
my $user_cfg = cfs_read_file('user.cfg');
|
||||||
|
my $user = $user_cfg->{users}->{$userid};
|
||||||
|
$user->{keys} = undef;
|
||||||
|
cfs_write_file('user.cfg', $user_cfg);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
cfs_write_file('priv/tfa.cfg', $tfa_cfg);
|
cfs_write_file('priv/tfa.cfg', $tfa_cfg);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user