summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-19 15:56:54 -0400
committerDaniel Friesel <derf@finalrewind.org>2019-04-19 15:56:54 -0400
commit24d0943cdc3f50ac1063b6fb8308ce21d940c67d (patch)
tree3c6144f13dad9e848f5a8c1dfb0f8dbedaa0b976
parentf7db1c6a2642238b440aba39ee7e9133dfd1e901 (diff)
refactor set_status_query and get_token_query
-rwxr-xr-xlib/Travelynx.pm37
-rw-r--r--lib/Travelynx/Controller/Account.pm2
2 files changed, 9 insertions, 30 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 6fd2ee2..6ab89fe 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -209,17 +209,6 @@ sub startup {
}
);
$self->attr(
- set_status_query => sub {
- my ($self) = @_;
-
- return $self->app->dbh->prepare(
- qq{
- update users set status = ? where id = ?;
- }
- );
- }
- );
- $self->attr(
mark_for_deletion_query => sub {
my ($self) = @_;
@@ -448,19 +437,6 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
}
);
$self->attr(
- get_token_query => sub {
- my ($self) = @_;
-
- return $self->app->dbh->prepare(
- qq{
- select
- name, status, token
- from users where id = ?
- }
- );
- }
- );
- $self->attr(
get_stationid_by_ds100_query => sub {
my ($self) = @_;
@@ -1019,11 +995,14 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
'get_user_token' => sub {
my ( $self, $uid ) = @_;
- my $query = $self->app->get_token_query;
- $query->execute($uid);
- my $rows = $query->fetchall_arrayref;
- if ( @{$rows} ) {
- return @{ $rows->[0] };
+ my $res = $self->pg->db->select(
+ 'users',
+ [ 'name', 'status', 'token' ],
+ { id => $uid }
+ );
+
+ if ( my $ret = $res->array ) {
+ return @{$ret};
}
return;
}
diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm
index 9e8c1fb..8626dc8 100644
--- a/lib/Travelynx/Controller/Account.pm
+++ b/lib/Travelynx/Controller/Account.pm
@@ -171,7 +171,7 @@ sub verify {
$self->render( 'register', invalid => 'token' );
return;
}
- $self->app->set_status_query->execute( 1, $id );
+ $self->app->pg->db->update( 'users', { status => 1 }, { id => $id } );
$self->render( 'login', from => 'verification' );
}