layout; routing; login

This commit is contained in:
2022-12-22 00:29:06 +01:00
parent 85d99d8023
commit c894022b31
13 changed files with 116 additions and 47 deletions

View File

@ -1,5 +1,6 @@
<?php
//require __DIR__ . '/classes/JwtHandler.php';
require __DIR__ . '/classes/lib.php';
//class Auth extends JwtHandler
class Auth
@ -53,26 +54,17 @@ class Auth
isset($data['data']->id) &&
$user = $this->fetchUser($data['data']->id)
) :
return [
"success" => 1,
"message" => "User found",
"user" => $user
];
$retVal = new CMsg(1, 200, "User found", null, $user);
return $retVal->jsonarray();
else :
return [
"success" => 0,
"message" => $data['message'],
"user" => null
];
$retVal = new CMsg(0, 422, $data['message'], null, null);
return $retVal->jsonarray();
endif;
}
else
{
return [
"success" => 0,
"message" => "User not found in request",
"user" => null
];
$retVal = new CMsg(0, 422, "User not found in request", null, null);
return $retVal->jsonarray();
}
}
@ -86,10 +78,9 @@ class Auth
if ($query_stmt->rowCount()) :
$returnVal = $query_stmt->fetch(PDO::FETCH_ASSOC);
$returnVal->session = $_SESSION;
return $returnVal;
else :
return false;
return null;
endif;
} catch (PDOException $e) {
return null;

View File

@ -15,5 +15,5 @@ $db_connection = new Database();
$conn = $db_connection->dbConnection();
$auth = new Auth($conn, $allHeaders);
echo json_encode($auth->isValid());
echo $auth->isValid();
?>