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

(-)a/C4/Auth.pm (-1 lines)
Lines 308-314 sub get_template_and_user { Link Here
308
        $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber
308
        $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber
309
        $template->param( logged_in_user     => $patron );
309
        $template->param( logged_in_user     => $patron );
310
        $template->param( sessionID          => $sessionID );
310
        $template->param( sessionID          => $sessionID );
311
        $template->param( csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $sessionID }));
312
311
313
        if ( $in->{'type'} eq 'opac' ) {
312
        if ( $in->{'type'} eq 'opac' ) {
314
            require Koha::Virtualshelves;
313
            require Koha::Virtualshelves;
(-)a/Koha/Template/Plugin/Koha.pm (+27 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use base qw( Template::Plugin );
22
use base qw( Template::Plugin );
23
23
24
use C4::Context;
24
use C4::Context;
25
use Koha::Token;
25
use Koha;
26
use Koha;
26
27
27
=head1 NAME
28
=head1 NAME
Lines 48-55 is necessary. Link Here
48
49
49
=head2 Class Methods
50
=head2 Class Methods
50
51
52
=head3 new
53
54
This new method allows us to store the context which gives us
55
access to the template vars already set. In particular this gives
56
us access to the template vars set by C4::Auth::get_template_and_user
57
51
=cut
58
=cut
52
59
60
sub new {
61
    my ( $class, $context ) = @_;
62
    bless {
63
        _CONTEXT => $context,
64
    }, $class;
65
}
66
67
53
sub Preference {
68
sub Preference {
54
    my ( $self, $pref ) = @_;
69
    my ( $self, $pref ) = @_;
55
    return C4::Context->preference( $pref );
70
    return C4::Context->preference( $pref );
Lines 84-87 sub Version { Link Here
84
    };
99
    };
85
}
100
}
86
101
102
=head3 GenerateCSRF
103
104
Generate a new CSRF token.
105
106
=cut
107
108
sub GenerateCSRF {
109
    my ( $self ) = @_;
110
    my $session_id = $self->{_CONTEXT}->stash->{sessionID};
111
    return Koha::Token->new->generate_csrf({ session_id => scalar $session_id });
112
}
113
87
1;
114
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/csrf-token.inc (-2 / +3 lines)
Line 1 Link Here
1
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
1
[%- USE Koha %]
2
[%- USE raw %]
3
<input type="hidden" name="csrf_token" value="[% Koha.GenerateCSRF | $raw %]" />
2
- 

Return to bug 30524