Unverified Commit 58eefe42 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

fix(frontend): set timeout admin longer in management (#1378)

issue #1286
parent ec4d3f8e
...@@ -22,8 +22,14 @@ ...@@ -22,8 +22,14 @@
,monitoring => 0 ,monitoring => 0
,guide => '' ,guide => ''
,guide_custom => '' ,guide_custom => ''
# normal users session timeout
,session_timeout => 5*60 ,session_timeout => 5*60
# session timeout when admin logs in
,session_timeout_admin => 15*60 ,session_timeout_admin => 15*60
# session timeout when admin enters management pages
,session_timeout_admin2 => 60*60
,auto_view => 0 ,auto_view => 0
,fallback => 0 ,fallback => 0
}; };
...@@ -118,6 +118,7 @@ our $DOCUMENT_ROOT = "/var/www"; ...@@ -118,6 +118,7 @@ our $DOCUMENT_ROOT = "/var/www";
our $SESSION_TIMEOUT = ($CONFIG_FRONT->{session_timeout} or 5 * 60); our $SESSION_TIMEOUT = ($CONFIG_FRONT->{session_timeout} or 5 * 60);
# session times out in 15 minutes for admin users # session times out in 15 minutes for admin users
our $SESSION_TIMEOUT_ADMIN = ($CONFIG_FRONT->{session_timeout_admin} or 15 * 60); our $SESSION_TIMEOUT_ADMIN = ($CONFIG_FRONT->{session_timeout_admin} or 15 * 60);
our $SESSION_TIMEOUT_ADMIN2 = ($CONFIG_FRONT->{session_timeout_admin2} or 60 * 60);
my $WS = Ravada::WebSocket->new(ravada => $RAVADA); my $WS = Ravada::WebSocket->new(ravada => $RAVADA);
my %ALLOWED_ANONYMOUS_WS = map { $_ => 1 } qw(list_bases_anonymous list_alerts); my %ALLOWED_ANONYMOUS_WS = map { $_ => 1 } qw(list_bases_anonymous list_alerts);
...@@ -1411,7 +1412,7 @@ websocket '/ws/subscribe' => sub { ...@@ -1411,7 +1412,7 @@ websocket '/ws/subscribe' => sub {
my $c = shift; my $c = shift;
my $expiration = $SESSION_TIMEOUT; my $expiration = $SESSION_TIMEOUT;
return if !$USER; return if !$USER;
$expiration = $SESSION_TIMEOUT_ADMIN if $USER->is_admin; $expiration = $SESSION_TIMEOUT_ADMIN if $USER->is_operator;
$c->inactivity_timeout( $expiration ); $c->inactivity_timeout( $expiration );
$c->on(message => sub { $c->on(message => sub {
my ($ws, $channel ) = @_; my ($ws, $channel ) = @_;
...@@ -1694,6 +1695,7 @@ sub admin { ...@@ -1694,6 +1695,7 @@ sub admin {
if ($page eq 'nodes') { if ($page eq 'nodes') {
Ravada::Request->refresh_vms(); Ravada::Request->refresh_vms();
} }
$c->session(expiration => $SESSION_TIMEOUT_ADMIN2);
if ($page eq 'settings') { if ($page eq 'settings') {
my $url = $c->req->url->to_abs->path; my $url = $c->req->url->to_abs->path;
my $host = $c->req->url->to_abs->host; my $host = $c->req->url->to_abs->host;
......
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