Bug 31378: Use base URLs for redirect uri

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2022-11-03 09:25:53 -03:00 committed by Tomas Cohen Arazi
parent 9c5f6e8c17
commit 9e2cf4d358
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 4 additions and 1 deletions

View File

@ -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;