Skip to content

Commit

Permalink
improve login redirect
Browse files Browse the repository at this point in the history
do not redirect on default referer
  • Loading branch information
sni committed Aug 5, 2024
1 parent ce235ca commit 65e0003
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Thruk/Controller/login.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sub index {
my $cookie_domain = $c->get_cookie_domain();

my $keywords = $c->req->uri->query;
my $has_query = $c->req->uri->query ? 1 : 0;
my $logoutref;
if($keywords and $keywords =~ m/^logout(\/.*)/mx) {
$keywords = 'logout';
Expand Down Expand Up @@ -125,7 +126,7 @@ sub index {
}

# simply redirect if already authenticated
if($referer && $c->cookies('thruk_auth') && $c->authenticate()) {
if($has_query && $referer && $c->cookies('thruk_auth') && $c->authenticate()) {
$referer = '/'.$referer if $referer !~ m|^/|mx;
return $c->redirect_to($referer);
}
Expand Down

0 comments on commit 65e0003

Please sign in to comment.