From 7b99462c4ae385ae930d497b0196406519117707 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 3 Nov 2022 09:25:53 -0300 Subject: [PATCH] Bug 31378: Use base URLs for redirect uri Signed-off-by: Lukasz Koszyk --- Koha/REST/V1/OAuth/Client.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Koha/REST/V1/OAuth/Client.pm b/Koha/REST/V1/OAuth/Client.pm index f3256ce3f5..19079a31e1 100644 --- a/Koha/REST/V1/OAuth/Client.pm +++ b/Koha/REST/V1/OAuth/Client.pm @@ -51,14 +51,17 @@ sub login { my $provider_config = $c->oauth2->providers->{$provider}; my $uri; + my $base_url; if ( $interface eq 'opac' ) { + $base_url = C4::Context->preference('OPACBaseURL'); if ( C4::Context->preference('OpacPublic') ) { $uri = '/cgi-bin/koha/opac-user.pl'; } else { $uri = '/cgi-bin/koha/opac-main.pl'; } } else { + $base_url = C4::Context->preference('staffClientBaseURL'); $uri = '/cgi-bin/koha/mainpage.pl'; } @@ -73,7 +76,7 @@ sub login { $provider_config->{authorize_url} = $authorize_url->to_string; } - return $c->oauth2->get_token_p($provider)->then( + return $c->oauth2->get_token_p( $provider, { redirect_uri => $base_url . '/api/v1/public/oauth/login/' . $provider . "/" . $interface } )->then( sub { return unless my $response = shift; -- 2.25.1