diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-03-04 18:17:03 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-03-04 18:17:03 +0100 |
commit | 8adca327fd976b117ccfa4d69903ee24e4f9bca4 (patch) | |
tree | dda13d7cf370ab4bdc9e45029f6f391d81741b23 /index.pl | |
parent | 3096091f1130f36df61d0845f4e026cd970ce66c (diff) |
prepare DB schema for public registration0.04
Diffstat (limited to 'index.pl')
-rwxr-xr-x | index.pl | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -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) = @_; |