Skip to content

Commit

Permalink
wip: deny remove base
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Jan 22, 2024
1 parent ce221e2 commit b872693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4978,9 +4978,14 @@ sub _cmd_remove_base {
my $user = Ravada::Auth::SQL->search_by_id( $uid);

my $domain = $self->search_domain_by_id($id_domain);

die "Unknown domain id '$id_domain'\n" if !$domain;

die "User ".$user->name." [".$user->id."] not allowed to remove base "
.$domain->name."\n"
unless $user->is_admin || (
$domain->id_owner == $user->id && $user->can_create_base());


$domain->remove_base($user);

}
Expand Down
4 changes: 2 additions & 2 deletions t/user/20_grants.t
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,11 @@ sub test_view_all($vm) {
wait_request( check_error => 0, debug => 0);
for my $req ($req_prepare, $req_remove_base, $req_shutdown) {
is($req->status,'done');
like($req->error,qr'User.* (can.t |not allowed)', $req->command);
like($req->error,qr'User.* (can.t |not allowed)', $req->command)
or exit;
}
for my $req ( $req_start_admin, $req_prepare_admin, $req_start
,$req_refresh, $req_refresh_ports) {
diag($req->command);
is($req->status,'done');
next if $req->command =~ /refresh_machine_ports/i;
is($req->error,'', $req->command) or exit;
Expand Down

0 comments on commit b872693

Please sign in to comment.