Added in editor login feature to login into editor

Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
2022-07-29 20:00:36 +01:00
parent 315a0484b0
commit 90a3e4f533
31 changed files with 831 additions and 478 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace api;
use PDO;
require_once "./config.php";
/**
* User Class
* Define all functions which either check, update or delete user data
*/
class user
{
function checkUser($username, $password): bool
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(":username", $username);
$stmt->execute();
// set the resulting array to associative
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($result)
{
if (password_verify($password, $result[0]["password"]))
{
return true;
}
return false;
}
return false;
}
function createToken(): string
{
return uniqid("rpe-");
}
}