summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-04 18:17:03 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-04 18:17:03 +0100
commit8adca327fd976b117ccfa4d69903ee24e4f9bca4 (patch)
treedda13d7cf370ab4bdc9e45029f6f391d81741b23 /index.pl
parent3096091f1130f36df61d0845f4e026cd970ce66c (diff)
prepare DB schema for public registration0.04
Diffstat (limited to 'index.pl')
-rwxr-xr-xindex.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index 71ecd92..513cf29 100755
--- a/index.pl
+++ b/index.pl
@@ -178,6 +178,20 @@ app->attr(
}
);
app->attr(
+ get_user_query => sub {
+ my ($self) = @_;
+
+ return $self->app->dbh->prepare(
+ qq{
+ select
+ id, name, status, is_public, email,
+ registered_at, last_login, deletion_requested
+ from users where id = ?
+ }
+ );
+ }
+);
+app->attr(
get_stationid_by_ds100_query => sub {
my ($self) = @_;
@@ -445,6 +459,35 @@ helper 'get_station_id' => sub {
}
};
+helper 'get_user_data' => sub {
+ my ($self) = @_;
+
+ my $uid = $self->get_user_id;
+ my $query = $self->app->get_user_query;
+ $query->execute($uid);
+ my $rows = $query->fetchall_arrayref;
+ if ( @{$rows} ) {
+ my @row = @{ $rows->[0] };
+ return {
+ id => $row[0],
+ name => $row[1],
+ status => $row[2],
+ is_public => $row[3],
+ email => $row[4],
+ registered_at => DateTime->from_epoch(
+ epoch => $row[5],
+ time_zone => 'Europe/Berlin'
+ ),
+ last_seen => DateTime->from_epoch(
+ epoch => $row[6],
+ time_zone => 'Europe/Berlin'
+ ),
+ deletion_requested => $row[7]
+ };
+ }
+ return;
+};
+
helper 'get_user_name' => sub {
my ($self) = @_;