(airhead): ive no idea no lie

Signed-off-by: boris <boris@borishub.co.uk>
This commit is contained in:
boris
2024-12-04 21:13:46 +00:00
parent 5b0d04b702
commit 8de2b7f29e
32 changed files with 233 additions and 1103 deletions

View File

@@ -10,6 +10,10 @@ class User {
public function getUserId() {
return $this->_userId;
}
/**
* Open session, set field variables
*/
public function __construct() {
session_start();
@@ -17,7 +21,7 @@ class User {
$this->_loggedIn = false;
$this->_userId = "0";
$this->_accessLevel = null;
// if user logged in, set variables.
if(isset($_SESSION['login'])) {
$this->_username = $_SESSION['login'];
$this->_userId = $_SESSION['uid'];
@@ -26,17 +30,6 @@ class User {
}
}
public function init() {
$this->_username = "None";
$this->_userId = "0";
$this->_loggedIn = false;
if(isset($_SESSION['login'])) {
$this->_username = $_SESSION['login'];
$this->_userId = $_SESSION['uid'];
$this->_loggedIn = true;
}
}
private function setAccessLevel($level) {
$this->_accessLevel = $level;
$_SESSION['accessLevel'] = $level;
@@ -44,6 +37,13 @@ class User {
public function getAccessLevel() {
return $this->_accessLevel;
}
/**
* @param $username
* @param $password
* @return bool
* Using a username and password, authenticate a user and assign variables from query
*/
public function Authenticate($username, $password): bool
{
$users = new UserDataSet();
@@ -64,6 +64,10 @@ class User {
}
}
/**
* @return void
* Unset user variables from session, and set variables to default values - destroying session.
*/
public function logout() {
unset($_SESSION['login']);
unset($_SESSION['uid']);