Refactored/ streamlined UserSession code

Makes it easier to tell when a user is signed in
This commit is contained in:
2019-05-24 23:53:49 +02:00
parent 09e9e616ec
commit be9e69c71c
9 changed files with 33 additions and 31 deletions

View File

@@ -1,3 +1,4 @@
<?php
session_destroy();
session_start();
?>

View File

@@ -1,7 +1,4 @@
<?php
include_once("./controller/UserSession.php");
if(UserSession::isSessionValid()){
Database::invalidateSession(UserSession::getSession()->token);
}
Database::invalidateSession($_COOKIE['usersession']);
session_destroy();
?>

View File

@@ -1,7 +0,0 @@
<?php
include_once("./controller/UserSession.php");
if(UserSession::isSessionValid()){
Database::invalidateSession(UserSession::getSession()->token);
session_destroy();
}
?>

View File

@@ -3,7 +3,7 @@ $debuginfo = false;
include_once("./controller/UserSession.php");
include_once("./controller/Database.php");
include_once("./controller/HUtils.php");
if(!UserSession::isSessionValid()){
if(!UserSession::isUserSignedIn()){
if(HUtils::issetPost(['email','password'])){
if(Database::isLoginValid($_POST['email'], $_POST['password'])){
//obtain UID
@@ -17,7 +17,7 @@ if(!UserSession::isSessionValid()){
while(Database::isSessionTokenInUse($token)){
$token = UserSession::generateToken();
}
$a = new UserSession($username, $uid, $token);
$a = new UserSession($uid, $token);
if($debuginfo){
echo $a->getSessionToken();
echo "<br>";