Commit 1ea469c8 authored by Fernando Verdugo's avatar Fernando Verdugo Committed by Francesc Guasch
Browse files

Feature/1145 directly (#1176)

feat(frontend): direct access if only one machine

Check number of machines
If user only has one clone, redirect to file.vv and open spice client

Issue #1145 
parent 4b98eef4
......@@ -337,6 +337,10 @@ sub _load_allowed {
return if !$refresh && $self->{_load_allowed}++;
if (ref($self) !~ /SQL$/) {
$self = Ravada::Auth::SQL->new(name => $self->name);
}
my $ldap_entry;
$ldap_entry = $self->ldap_entry if $self->external_auth && $self->external_auth eq 'ldap';
......
......@@ -1294,9 +1294,10 @@ sub login {
$auth_ok = Ravada::Auth::SQL->new(name => $auth_ok->name);
my $machines = $RAVADA->list_machines_user($auth_ok);
$url = "/machine/display/". $machines->[0]->{id_clone}.".vv" if scalar(@$machines) == 1 && $machines->[0]->{id_clone};
$url = "/machine/clone/". $machines->[0]->{id}.".html" if scalar(@$machines) == 1 && !($auth_ok->is_admin);
my $auto_view = 1;
$c->session(expiration => $expiration);
$c->session(auto_view => $auto_view, expiration => $expiration);
return $c->redirect_to($url);
} else {
push @error,("Access denied");
......
......@@ -90,6 +90,8 @@ sub test_user{
.Dumper($mcnulty->{_data}));
ok($mcnulty->ldap_entry,"Expecting User LDAP entry");
eval { $mcnulty->allowed_access(1) };
is($@,'');
# try to login
my $mcnulty_login = Ravada::Auth::login($name,$password);
ok($mcnulty_login,"No login");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment