#!/usr/local/bin/perl
# delete_user.cgi
# Delete a webmin user

require './acl-lib.pl';
&ReadParse();
&error_setup($text{'delete_err'});
$access{'delete'} || &error($text{'delete_ecannot'});
&can_edit_user($in{'user'}) || &error($text{'delete_euser'});
if ($base_remote_user eq $in{'user'}) {
	&error($text{'delete_eself'});
	}
&delete_user($in{'user'});
foreach $g (&list_groups()) {
	local @mems = @{$g->{'members'}};
	local $i = &indexof($in{'user'}, @mems);
	if ($i >= 0) {
		splice(@mems, $i, 1);
		$g->{'members'} = \@mems;
		&modify_group($g->{'name'}, $g);
		}
	}
&restart_miniserv();
&webmin_log("delete", "user", $in{'user'});
&redirect("");

