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

(-)a/Koha/ILL/Backend/Standard.pm (-2 / +4 lines)
Lines 296-303 sub create { Link Here
296
            C4::Context->preference("ILLOpacUnauthenticatedRequest") && !$other->{'cardnumber'};
296
            C4::Context->preference("ILLOpacUnauthenticatedRequest") && !$other->{'cardnumber'};
297
        if ($unauthenticated_request) {
297
        if ($unauthenticated_request) {
298
            ( $failed, $result ) = _validate_form_params( $other, $result, $params );
298
            ( $failed, $result ) = _validate_form_params( $other, $result, $params );
299
            if ( !Koha::ILL::Request::unauth_request_data_check($other) ) {
299
            return $result if $failed;
300
                $result->{status} = "missing_unauth_data";
300
            my $unauth_request_error = Koha::ILL::Request::unauth_request_data_error($other);
301
            if ($unauth_request_error) {
302
                $result->{status} = $unauth_request_error;
301
                $result->{value}  = $params;
303
                $result->{value}  = $params;
302
                $failed           = 1;
304
                $failed           = 1;
303
            }
305
            }
(-)a/Koha/ILL/Backend/opac-includes/create.inc (+18 lines)
Lines 27-32 Link Here
27
    <div class="alert alert-warning">
27
    <div class="alert alert-warning">
28
        <strong>Please note:</strong> The library you chose is invalid.
28
        <strong>Please note:</strong> The library you chose is invalid.
29
    </div>
29
    </div>
30
[% ELSIF whole.status == 'failed_captcha' %]
31
    <div class="alert alert-warning">You typed in the wrong characters in the box before submitting. Please try again.</div>
30
[% ELSE %]
32
[% ELSE %]
31
<p>Unhandled error</p>
33
<p>Unhandled error</p>
32
[% END %]
34
[% END %]
Lines 119-124 Link Here
119
      [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %]
121
      [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %]
120
  [% END %]
122
  [% END %]
121
  [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %]
123
  [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %]
124
  [% IF whole.value.other.type && unauthenticated_ill && !logged_in_user%]
125
    <fieldset class="rows" id="illrequest_captcha">
126
        <legend>Verification</legend>
127
        <ol>
128
            <li>
129
                <label for="captcha" class="required">Verification:</label>
130
131
                <input type="text" name="captcha" id="captcha" class="form-control input-fluid" style="text-transform: uppercase;" />
132
                <div class="required_label required">Required</div>
133
                <input type="hidden" name="captcha_digest" value="[% captcha_digest | html %]" />
134
135
                <span class="hint">Please type the following characters into the preceding box: <strong>[% captcha | html %]</strong></span>
136
            </li>
137
        </ol>
138
    </fieldset>
139
  [% END %]
122
  <fieldset class="action">
140
  <fieldset class="action">
123
    <input id="ill-submit" class="btn btn-primary" type="submit" value="Create"/>
141
    <input id="ill-submit" class="btn btn-primary" type="submit" value="Create"/>
124
    <a class="cancel" href="/cgi-bin/koha/opac-illrequests.pl">Cancel</a>
142
    <a class="cancel" href="/cgi-bin/koha/opac-illrequests.pl">Cancel</a>
(-)a/Koha/ILL/Request.pm (-8 / +10 lines)
Lines 1968-1990 sub add_unauthenticated_data { Link Here
1968
    );
1968
    );
1969
}
1969
}
1970
1970
1971
=head3 unauth_request_data_check
1971
=head3 unauth_request_data_error
1972
1972
1973
    unauth_request_data_check($metadata);
1973
    unauth_request_data_error($metadata);
1974
1974
1975
Checks if unauthenticated request data is present
1975
Checks if unauthenticated request data errored, returns error_code if so, else 0
1976
1976
1977
=cut
1977
=cut
1978
1978
1979
sub unauth_request_data_check {
1979
sub unauth_request_data_error {
1980
    my ($metadata) = @_;
1980
    my ($metadata) = @_;
1981
1981
1982
    return 1 unless C4::Context->preference("ILLOpacUnauthenticatedRequest");
1982
    return 0 unless C4::Context->preference("ILLOpacUnauthenticatedRequest");
1983
1983
    return 'missing_unauth_data'
1984
    return
1984
        unless $metadata->{unauthenticated_first_name}
1985
           $metadata->{unauthenticated_first_name}
1986
        && $metadata->{unauthenticated_last_name}
1985
        && $metadata->{unauthenticated_last_name}
1987
        && $metadata->{unauthenticated_email};
1986
        && $metadata->{unauthenticated_email};
1987
1988
    return 'failed_captcha' if $metadata->{failed_captcha};
1989
    return 0;
1988
}
1990
}
1989
1991
1990
=head3 append_to_note
1992
=head3 append_to_note
(-)a/opac/opac-illrequests.pl (-3 / +19 lines)
Lines 24-31 use JSON qw( encode_json ); Link Here
24
use CGI      qw ( -utf8 );
24
use CGI      qw ( -utf8 );
25
use C4::Auth qw( get_template_and_user );
25
use C4::Auth qw( get_template_and_user );
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output     qw( output_html_with_http_headers );
28
use POSIX      qw( strftime );
28
use Digest::MD5    qw( md5_base64 );
29
use POSIX          qw( strftime );
30
use String::Random qw( random_string );
29
31
30
use Koha::ILL::Request::Config;
32
use Koha::ILL::Request::Config;
31
use Koha::ILL::Requests;
33
use Koha::ILL::Requests;
Lines 119-124 if ( $op eq 'list' ) { Link Here
119
        my $req = Koha::ILL::Request->new;
121
        my $req = Koha::ILL::Request->new;
120
        $template->param( backends => $backends );
122
        $template->param( backends => $backends );
121
    } else {
123
    } else {
124
125
        if ( C4::Context->preference('ILLOpacUnauthenticatedRequest') && !$patron ) {
126
            my $captcha = random_string("CCCCC");
127
            $template->param(
128
                captcha        => $captcha,
129
                captcha_digest => md5_base64($captcha),
130
            );
131
        }
132
122
        $params->{backend} = 'Standard' if $params->{backend} eq 'FreeForm';
133
        $params->{backend} = 'Standard' if $params->{backend} eq 'FreeForm';
123
        my $request = Koha::ILL::Request->new->load_backend( $params->{backend} );
134
        my $request = Koha::ILL::Request->new->load_backend( $params->{backend} );
124
135
Lines 155-160 if ( $op eq 'list' ) { Link Here
155
            exit;
166
            exit;
156
        }
167
        }
157
168
169
        if ( $request->_backend_capability( 'can_create_request', $params ) ) {
170
            if ( md5_base64( uc( $params->{captcha} ) ) ne $params->{captcha_digest} ) {
171
                $params->{failed_captcha} = 1;
172
            }
173
        }
174
158
        $params->{cardnumber} = $patron->cardnumber if $patron;
175
        $params->{cardnumber} = $patron->cardnumber if $patron;
159
        $params->{branchcode} = $patron->branchcode if $patron;
176
        $params->{branchcode} = $patron->branchcode if $patron;
160
        $params->{opac}       = 1;
177
        $params->{opac}       = 1;
161
- 

Return to bug 36197