Lines 43-67
Controller method handling login requests
Link Here
|
43 |
sub login { |
43 |
sub login { |
44 |
my $c = shift->openapi->valid_input or return; |
44 |
my $c = shift->openapi->valid_input or return; |
45 |
|
45 |
|
46 |
my $provider = $c->validation->param('provider_code'); |
46 |
my $provider = $c->param('provider_code'); |
47 |
my $interface = $c->validation->param('interface'); |
47 |
my $interface = $c->param('interface'); |
48 |
|
48 |
|
49 |
my $logger = Koha::Logger->get({ interface => 'api' }); |
49 |
my $logger = Koha::Logger->get({ interface => 'api' }); |
50 |
|
50 |
|
51 |
my $provider_config = $c->oauth2->providers->{$provider}; |
51 |
my $provider_config = $c->oauth2->providers->{$provider}; |
52 |
|
52 |
|
53 |
my $uri; |
53 |
my $uri; |
54 |
my $base_url; |
54 |
my $redirect_url; |
55 |
|
55 |
|
56 |
if ( $interface eq 'opac' ) { |
56 |
if ( $interface eq 'opac' ) { |
57 |
$base_url = C4::Context->preference('OPACBaseURL'); |
57 |
$redirect_url = C4::Context->preference('OPACBaseURL') . '/api/v1/public/oauth/login/'; |
58 |
if ( C4::Context->preference('OpacPublic') ) { |
58 |
if ( C4::Context->preference('OpacPublic') ) { |
59 |
$uri = '/cgi-bin/koha/opac-user.pl'; |
59 |
$uri = '/cgi-bin/koha/opac-user.pl'; |
60 |
} else { |
60 |
} else { |
61 |
$uri = '/cgi-bin/koha/opac-main.pl'; |
61 |
$uri = '/cgi-bin/koha/opac-main.pl'; |
62 |
} |
62 |
} |
63 |
} else { |
63 |
} else { |
64 |
$base_url = C4::Context->preference('staffClientBaseURL'); |
64 |
$redirect_url = C4::Context->preference('staffClientBaseURL') . '/api/v1/oauth/login/'; |
65 |
$uri = '/cgi-bin/koha/mainpage.pl'; |
65 |
$uri = '/cgi-bin/koha/mainpage.pl'; |
66 |
} |
66 |
} |
67 |
|
67 |
|
Lines 76-82
sub login {
Link Here
|
76 |
$provider_config->{authorize_url} = $authorize_url->to_string; |
76 |
$provider_config->{authorize_url} = $authorize_url->to_string; |
77 |
} |
77 |
} |
78 |
|
78 |
|
79 |
return $c->oauth2->get_token_p( $provider, { redirect_uri => $base_url . '/api/v1/public/oauth/login/' . $provider . "/" . $interface } )->then( |
79 |
return $c->oauth2->get_token_p( $provider, { redirect_uri => $redirect_url . $provider . "/" . $interface } )->then( |
80 |
sub { |
80 |
sub { |
81 |
return unless my $response = shift; |
81 |
return unless my $response = shift; |
82 |
|
82 |
|
83 |
- |
|
|