Added proper session handling while in development mode
This commit is contained in:
parent
55b8b75c0e
commit
45db7e7b93
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
/logs/*
|
/logs/*
|
||||||
|
/tmp/
|
||||||
|
@ -12,8 +12,13 @@
|
|||||||
* Jelmer Hinssen
|
* Jelmer Hinssen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Create session
|
/**
|
||||||
session_start();
|
* Session fix for development
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (session_save_path() === "") {
|
||||||
|
ini_set('session.save_path', realpath(__DIR__ . '/../tmp'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the script is running in CLI mode
|
* Check if the script is running in CLI mode
|
||||||
|
@ -33,17 +33,22 @@ class Authorization
|
|||||||
$klantnr = $rekeningen[$id]['klantid'];
|
$klantnr = $rekeningen[$id]['klantid'];
|
||||||
|
|
||||||
$klant = $db->klanten->where('id', $klantnr)[$klantnr];
|
$klant = $db->klanten->where('id', $klantnr)[$klantnr];
|
||||||
if ($klant['code'] === $passcode) {
|
|
||||||
$_SESSION['user'] = $klant;
|
|
||||||
|
|
||||||
|
if ($klant['code'] === $passcode) {
|
||||||
|
$_SESSION['userid'] = $klant['id'];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser()
|
public function getUserID()
|
||||||
{
|
{
|
||||||
return $_SESSION['user'];
|
return $_SESSION['userid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isUserAuthenticated()
|
||||||
|
{
|
||||||
|
return $this->getUserID() !== null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
* BOOTSTRAPPING SCRIPT
|
* BOOTSTRAPPING SCRIPT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
// Get the Slim framework settings
|
// Get the Slim framework settings
|
||||||
$settings = require __DIR__ . '/settings.php';
|
$settings = require __DIR__ . '/settings.php';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user