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 (+26 lines)
Lines 48-55 is necessary. Link Here
48
48
49
=head2 Class Methods
49
=head2 Class Methods
50
50
51
=head3 new
52
53
This new method allows us to store the context which gives us
54
access to the template vars already set. In particular this gives
55
us access to the template vars set by C4::Auth::get_template_and_user
56
51
=cut
57
=cut
52
58
59
sub new {
60
    my ( $class, $context ) = @_;
61
    bless {
62
        _CONTEXT => $context,
63
    }, $class;
64
}
65
66
53
sub Preference {
67
sub Preference {
54
    my ( $self, $pref ) = @_;
68
    my ( $self, $pref ) = @_;
55
    return C4::Context->preference( $pref );
69
    return C4::Context->preference( $pref );
Lines 84-87 sub Version { Link Here
84
    };
98
    };
85
}
99
}
86
100
101
=head3 GenerateCSRF
102
103
Generate a new CSRF token.
104
105
=cut
106
107
sub GenerateCSRF {
108
    my ( $self ) = @_;
109
    my $session_id = $self->{_CONTEXT}->stash->{sessionID};
110
    return Koha::Token->new->generate_csrf({ session_id => scalar $session_id });
111
}
112
87
1;
113
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