View | Details | Raw Unified | Return to bug 34271
Collapse All | Expand All

(-)a/Koha/REST/V1.pm (-5 / +3 lines)
Lines 109-116 sub startup { Link Here
109
        # to catch bad ones.
109
        # to catch bad ones.
110
110
111
        # JSON::Validator uses confess, so trim call stack from the message.
111
        # JSON::Validator uses confess, so trim call stack from the message.
112
        my $logger = Koha::Logger->get({ interface => 'api' });
112
        $self->app->log->error("Warning: Could not load REST API spec bundle: " . $_);
113
        $logger->error("Warning: Could not load REST API spec bundle: " . $_);
114
113
115
        try {
114
        try {
116
115
Lines 135-141 sub startup { Link Here
135
        }
134
        }
136
        catch {
135
        catch {
137
            # JSON::Validator uses confess, so trim call stack from the message.
136
            # JSON::Validator uses confess, so trim call stack from the message.
138
            $logger->error("Warning: Could not load REST API spec bundle: " . $_);
137
            $self->app->log->error("Warning: Could not load REST API spec bundle: " . $_);
139
        };
138
        };
140
    };
139
    };
141
140
Lines 148-155 sub startup { Link Here
148
            $oauth_configuration->{ $provider->code } = decode_json( $provider->config );
147
            $oauth_configuration->{ $provider->code } = decode_json( $provider->config );
149
        }
148
        }
150
    } catch {
149
    } catch {
151
        my $logger = Koha::Logger->get( { interface => 'api' } );
150
        $self->app->log->warn( "Warning: Failed to fetch oauth configuration: " . $_ );
152
        $logger->warn( "Warning: Failed to fetch oauth configuration: " . $_ );
153
    };
151
    };
154
152
155
    $self->plugin( 'Koha::REST::Plugin::Pagination' );
153
    $self->plugin( 'Koha::REST::Plugin::Pagination' );
(-)a/Koha/REST/V1/OAuth/Client.pm (-6 / +2 lines)
Lines 23-29 use Mojo::Base 'Mojolicious::Controller'; Link Here
23
use Mojo::URL;
23
use Mojo::URL;
24
use Scalar::Util qw(blessed);
24
use Scalar::Util qw(blessed);
25
use Try::Tiny;
25
use Try::Tiny;
26
use Koha::Logger;
27
use Koha::Token;
26
use Koha::Token;
28
use URI::Escape qw(uri_escape_utf8);
27
use URI::Escape qw(uri_escape_utf8);
29
28
Lines 47-54 sub login { Link Here
47
    my $provider  = $c->param('provider_code');
46
    my $provider  = $c->param('provider_code');
48
    my $interface = $c->param('interface');
47
    my $interface = $c->param('interface');
49
48
50
    my $logger = Koha::Logger->get({ interface => 'api' });
51
52
    my $provider_config = $c->oauth2->providers->{$provider};
49
    my $provider_config = $c->oauth2->providers->{$provider};
53
50
54
    my $uri;
51
    my $uri;
Lines 132-138 sub login { Link Here
132
                $c->redirect_to($uri);
129
                $c->redirect_to($uri);
133
            } catch {
130
            } catch {
134
                my $error = $_;
131
                my $error = $_;
135
                $logger->error($error);
132
                $c->app->log->error($error);
136
                # TODO: Review behavior
133
                # TODO: Review behavior
137
                if ( blessed $error ) {
134
                if ( blessed $error ) {
138
                    if ( $error->isa('Koha::Exceptions::Auth::Unauthorized') ) {
135
                    if ( $error->isa('Koha::Exceptions::Auth::Unauthorized') ) {
Lines 151-157 sub login { Link Here
151
    )->catch(
148
    )->catch(
152
        sub {
149
        sub {
153
            my $error = shift;
150
            my $error = shift;
154
            $logger->error($error);
151
            $c->app->log->error($error);
155
            $error = uri_escape_utf8($error);
152
            $error = uri_escape_utf8($error);
156
            $c->redirect_to($uri."?auth_error=$error");
153
            $c->redirect_to($uri."?auth_error=$error");
157
        }
154
        }
158
- 

Return to bug 34271