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

(-)a/Koha/REST/V1/Auth.pm (-6 / +6 lines)
Lines 74-84 sub under { Link Here
74
            $is_plugin = 1;
74
            $is_plugin = 1;
75
        }
75
        }
76
76
77
        if ( $is_public
77
        if ( $is_public ) {
78
            and !C4::Context->preference('RESTPublicAPI') )
78
            Koha::Exceptions::UnderMaintenance->throw('Under maintenance')
79
        {
79
                if C4::Context->preference('OPACMaintenance');
80
            Koha::Exceptions::Authorization->throw(
80
            Koha::Exceptions::Authorization->throw(
81
                "Configuration prevents the usage of this endpoint by unprivileged users");
81
                "Configuration prevents the usage of this endpoint by unprivileged users")
82
                if !C4::Context->preference('RESTPublicAPI');
82
        }
83
        }
83
84
84
        if ( $c->req->url->to_abs->path =~ m#^/api/v1/oauth/# || $c->req->url->to_abs->path =~ m#^/api/v1/public/oauth/#) {
85
        if ( $c->req->url->to_abs->path =~ m#^/api/v1/oauth/# || $c->req->url->to_abs->path =~ m#^/api/v1/public/oauth/#) {
Lines 100-106 sub under { Link Here
100
            );
101
            );
101
        }
102
        }
102
        if ($_->isa('Koha::Exceptions::UnderMaintenance')) {
103
        if ($_->isa('Koha::Exceptions::UnderMaintenance')) {
103
            return $c->render(status => 503, json => { error => $_->error });
104
            return $c->render(status => 503, json => { error => $_->message });
104
        }
105
        }
105
        elsif ($_->isa('Koha::Exceptions::Authentication::SessionExpired')) {
106
        elsif ($_->isa('Koha::Exceptions::Authentication::SessionExpired')) {
106
            return $c->render(status => 401, json => { error => $_->error });
107
            return $c->render(status => 401, json => { error => $_->error });
107
- 

Return to bug 34999