Refactor session helper

This commit is contained in:
Tom Bloor 2017-04-18 18:31:10 +01:00
parent ddba771415
commit 13d1f8d4a7

View file

@ -274,17 +274,19 @@ $self->helper(get_session_expiry => sub {
#True for session was expire, false there was no session to expire. #True for session was expire, false there was no session to expire.
$self->helper(expire_current_session => sub { $self->helper(expire_current_session => sub {
my $self = shift; my $c = shift;
my $self = $c;
my $sessionToken = $self->get_session_token(); my $sessionToken = $self->get_session_token();
my $removeStatement = $self->db->prepare('DELETE FROM SessionTokens WHERE SessionTokenName = ?'); $c->schema->resultset('SessionToken')->search({
my $rowsRemoved = $removeStatement->execute($sessionToken); sessiontokenname => $sessionToken,
})->delete_all;
$self->session(expires => 1); $self->session(expires => 1);
$self->session->{$self->app->config->{sessionTokenJsonName}} = $sessionToken; $self->session->{$self->app->config->{sessionTokenJsonName}} = $sessionToken;
return $rowsRemoved != 0; return 1;
}); });
$self->helper(is_token_unused => sub { $self->helper(is_token_unused => sub {