Refactor session helper
This commit is contained in:
parent
ddba771415
commit
13d1f8d4a7
1 changed files with 12 additions and 10 deletions
|
@ -272,20 +272,22 @@ $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 {
|
||||||
my ( $c, $token ) = @_;
|
my ( $c, $token ) = @_;
|
||||||
|
|
Reference in a new issue