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
helper login => sub {
my $self = shift;
if ($self->session('id')){
if ($self->session('id') && $self->session('id') ne ''){
return 1;
}
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}->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->session( expires => 1 );
return 1;

Loading…
Cancel
Save