summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller/Api.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-22 12:11:22 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-22 12:11:22 +0200
commit2aece368035ab71a58f719f7ec526d566839980b (patch)
tree05d7d94e0b33b9891960bc32110c5d705cac6c38 /lib/Travelynx/Controller/Api.pm
parent4ed24c55653dafbac3053f57d6d3b094d4ad7fb5 (diff)
Use Mojo::Pg for all remaining Controller and Helper logic
Diffstat (limited to 'lib/Travelynx/Controller/Api.pm')
-rwxr-xr-xlib/Travelynx/Controller/Api.pm23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm
index c3eccb8..a9500f1 100755
--- a/lib/Travelynx/Controller/Api.pm
+++ b/lib/Travelynx/Controller/Api.pm
@@ -106,12 +106,27 @@ sub set_token {
}
if ( $self->param('action') eq 'delete' ) {
- $self->app->drop_api_token_query->execute( $self->current_user->{id},
- $token_id );
+ $self->pg->db->delete(
+ 'tokens',
+ {
+ user_id => $self->current_user->{id},
+ type => $token_id
+ }
+ );
}
else {
- $self->app->set_api_token_query->execute( $self->current_user->{id},
- $token_id, $token );
+ $self->pg->db->insert(
+ 'tokens',
+ {
+ user_id => $self->current_user->{id},
+ type => $token_id,
+ token => $token
+ },
+ {
+ on_conflict => \
+ '(user_id, type) do update set token = EXCLUDED.token'
+ },
+ );
}
$self->redirect_to('account');
}