Some fixes in API Key and session handling

master
Daniel Berteaud 10 years ago
parent 1368baec84
commit ae2d160f9e
  1. 7
      vroom.pl

@ -156,7 +156,7 @@ helper get_name => sub {
# And a new API key # And a new API key
helper login => sub { helper login => sub {
my $self = shift; my $self = shift;
if ($self->session('id')){ if ($self->session('id') && $self->session('id') ne ''){
return 1; return 1;
} }
my $id = $self->get_random(256); my $id = $self->get_random(256);
@ -188,6 +188,11 @@ helper logout => sub {
$peers->{$self->session('peer_id')}->{socket}){ $peers->{$self->session('peer_id')}->{socket}){
$peers->{$self->session('peer_id')}->{socket}->finish; $peers->{$self->session('peer_id')}->{socket}->finish;
} }
my $sth = eval {
$self->db->prepare('DELETE FROM `api_keys`
WHERE `token`=?');
};
$sth->execute($self->session('key'));
$self->app->log->info($self->get_name . " logged out"); $self->app->log->info($self->get_name . " logged out");
$self->session( expires => 1 ); $self->session( expires => 1 );
return 1; return 1;

Loading…
Cancel
Save