Skip to content
Snippets Groups Projects
Verified Commit de2df567 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Logovani kliku

parent 6fb61d74
No related branches found
No related tags found
No related merge requests found
Pipeline #10822 passed
...@@ -28,6 +28,8 @@ RUN cpanm \ ...@@ -28,6 +28,8 @@ RUN cpanm \
Mojo::Redis \ Mojo::Redis \
Mojo::JWT \ Mojo::JWT \
Mojolicious::Plugin::Authentication \ Mojolicious::Plugin::Authentication \
Mojolicious::Plugin::BrowserDetect \
Mojolicious::Plugin::ForwardedFor \
Mojolicious::Plugin::OpenAPI Mojolicious::Plugin::OpenAPI
ADD . /opt/PZ ADD . /opt/PZ
......
- statistika - statistika
- editace/smazani
- loop detect - loop detect
- 302 nebo informacni stranka - 302 nebo informacni stranka
1.0.1 1.1.0
...@@ -20,6 +20,7 @@ sub startup { ...@@ -20,6 +20,7 @@ sub startup {
# Delka session # Delka session
$self->sessions->default_expiration($cfg->{session}{lifetime}); $self->sessions->default_expiration($cfg->{session}{lifetime});
$self->plugin("ForwardedFor");
$self->plugin('PZ::Helpers::Core'); $self->plugin('PZ::Helpers::Core');
$self->plugin('PZ::Helpers::OIDC'); $self->plugin('PZ::Helpers::OIDC');
......
...@@ -16,6 +16,11 @@ sub redirect ($c) { ...@@ -16,6 +16,11 @@ sub redirect ($c) {
return; return;
} }
$shortcut->add_to_log_items({
ip => ($c->forwarded_for || $c->tx->remote_address),
ua => $c->req->headers->user_agent,
});
$c->res->code($shortcut->code); $c->res->code($shortcut->code);
$c->redirect_to($shortcut->url); $c->redirect_to($shortcut->url);
} }
......
...@@ -37,5 +37,9 @@ __PACKAGE__->add_unique_constraint( ...@@ -37,5 +37,9 @@ __PACKAGE__->add_unique_constraint(
'shortcut' => [qw(shortcut)] 'shortcut' => [qw(shortcut)]
); );
__PACKAGE__->has_many(
log_items => 'PZ::Schema::Result::Log',
{ 'foreign.shortcut_id' => 'self.id', },
);
1; 1;
...@@ -44,3 +44,6 @@ create table "log" ( ...@@ -44,3 +44,6 @@ create table "log" (
alter table "shortcuts" alter column "code" set default 302; alter table "shortcuts" alter column "code" set default 302;
alter table "shortcuts" drop constraint "shortcuts_shortcut_key"; alter table "shortcuts" drop constraint "shortcuts_shortcut_key";
create index "shortcuts_shortcut_idx" on "shortcuts" ("shortcut"); create index "shortcuts_shortcut_idx" on "shortcuts" ("shortcut");
-- 3 up
alter table "log" add column "ua" text;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment