my-portfolio/dist/api/user.php
rodude123 90a3e4f533 Added in editor login feature to login into editor
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-07-29 20:00:36 +01:00

38 lines
829 B
PHP

<?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-");
}
}