Frontend: Add logout_action

This commit is contained in:
mrkubax10 2023-09-09 10:58:26 +02:00
parent 1e7bea8e5f
commit eaea93fb9e
2 changed files with 15 additions and 0 deletions

View File

@ -116,6 +116,13 @@ sub handlePath {
$aClient->send($response); $aClient->send($response);
return 1; return 1;
} }
when("/logout_action") {
if(defined($aRequest->{"cookies"}{"session"})) {
frontend_session::deleteSession($aRequest->{"cookies"}{"session"});
}
frontend::redirect($aClient, "/");
return 1;
}
when("/view_logs") { when("/view_logs") {
my $channelID = $aRequest->{"path"}{"parameters"}{"channel"}; my $channelID = $aRequest->{"path"}{"parameters"}{"channel"};
if(!defined($channelID)) { if(!defined($channelID)) {

View File

@ -27,6 +27,14 @@ sub newSessionToken {
return Digest::SHA::sha256_hex(sprintf("%x", rand(0xFFFFFFFF))); return Digest::SHA::sha256_hex(sprintf("%x", rand(0xFFFFFFFF)));
} }
sub deleteSession {
my $aSession = $_[0];
if(isValidSession($aSession)) {
delete $sessions{$aSession};
}
}
sub isValidSession { sub isValidSession {
my $aSession = $_[0]; my $aSession = $_[0];