Initial commit

This commit is contained in:
Kwesi Banson Jnr
2026-04-08 05:53:02 +00:00
commit 592a161ee6
63 changed files with 4105 additions and 0 deletions

47
app/Models/Auth.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
class Auth {
private $connection;
// private $bearer_token;
public function __construct($db) {
$this->connection = $db;
}
public function read_api_auth(){
// $bearer = $this->bearer_token;
if(!function_exists('getallheaders')){
return false;
}
$headers = [];
foreach (getallheaders() as $name => $value) {
// echo "$name: $value <br>" . PHP_EOL;
$headers[$name] = $value;
}
$check = array_key_exists('Authorization', $headers);
if ($check == false) {
return false;
}
list($type, $bearer_token) = explode(" ", $headers['Authorization'], 2);
$query = 'SELECT id, name FROM auth_users WHERE bearer_token = ? LIMIT 0,1';
$statement = $this->connection->prepare($query);
$statement->bindParam(1, $bearer_token);
$statement->execute();
$row = $statement->fetch(PDO::FETCH_ASSOC);
if ($row == false) {
return false;
}
else{
return true;
}
}
}