Lines 24-29
use base qw( Template::Plugin );
Link Here
|
24 |
use C4::Context; |
24 |
use C4::Context; |
25 |
use Koha::Token; |
25 |
use Koha::Token; |
26 |
use Koha; |
26 |
use Koha; |
|
|
27 |
use Koha::Cache::Memory::Lite; |
27 |
|
28 |
|
28 |
=head1 NAME |
29 |
=head1 NAME |
29 |
|
30 |
|
Lines 107-114
Generate a new CSRF token.
Link Here
|
107 |
|
108 |
|
108 |
sub GenerateCSRF { |
109 |
sub GenerateCSRF { |
109 |
my ($self) = @_; |
110 |
my ($self) = @_; |
|
|
111 |
|
112 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
113 |
my $cache_key = "CSRF_TOKEN"; |
114 |
my $cached = $memory_cache->get_from_cache($cache_key); |
115 |
return $cached if $cached; |
116 |
|
110 |
my $session_id = $self->{_CONTEXT}->stash->{sessionID}; |
117 |
my $session_id = $self->{_CONTEXT}->stash->{sessionID}; |
111 |
return Koha::Token->new->generate_csrf( { session_id => scalar $session_id } ); |
118 |
my $csrf_token = Koha::Token->new->generate_csrf( { session_id => scalar $session_id } ); |
|
|
119 |
$memory_cache->set_in_cache( $cache_key, $csrf_token ); |
120 |
return $csrf_token; |
112 |
} |
121 |
} |
113 |
|
122 |
|
114 |
1; |
123 |
1; |
115 |
- |
|
|