summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-12 21:49:26 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-12 21:49:26 +0100
commit6ac88f40187864d4dd247c76de576dcbb4f15653 (patch)
tree78bea5ebb08b838ac9c8c45bc66bbe6f091920da /index.pl
parent2604abad4e685cb485922fc82feef54f805e3e36 (diff)
implement account deletion
Diffstat (limited to 'index.pl')
-rwxr-xr-xindex.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index caa25d2..4ddb44e 100755
--- a/index.pl
+++ b/index.pl
@@ -140,6 +140,17 @@ app->attr(
}
);
app->attr(
+ mark_for_deletion_query => sub {
+ my ($self) = @_;
+
+ return $self->app->dbh->prepare(
+ qq{
+ update users set deletion_requested = ? where id = ?;
+ }
+ );
+ }
+);
+app->attr(
checkin_query => sub {
my ($self) = @_;
@@ -614,6 +625,11 @@ helper 'get_user_data' => sub {
time_zone => 'Europe/Berlin'
),
deletion_requested => $row[7]
+ ? DateTime->from_epoch(
+ epoch => $row[7],
+ time_zone => 'Europe/Berlin'
+ )
+ : undef,
};
}
return undef;
@@ -1243,6 +1259,24 @@ get '/export.json' => sub {
);
};
+post '/delete' => sub {
+ my ($self) = @_;
+ if ( $self->validation->csrf_protect->has_error('csrf_token') ) {
+ $self->render( 'account', invalid => 'csrf' );
+ return;
+ }
+ my $now = DateTime->now( time_zone => 'Europe/Berlin' )->epoch;
+ if ( $self->param('action') eq 'delete' ) {
+ $self->app->mark_for_deletion_query->execute( $now,
+ $self->current_user->{id} );
+ }
+ else {
+ $self->app->mark_for_deletion_query->execute( undef,
+ $self->current_user->{id} );
+ }
+ $self->redirect_to('account');
+};
+
post '/logout' => sub {
my ($self) = @_;
if ( $self->validation->csrf_protect->has_error('csrf_token') ) {