2020-11-17 23:27:25 +01:00
|
|
|
<?php
|
2021-03-27 21:59:44 +01:00
|
|
|
use function _\find;
|
|
|
|
|
|
|
|
include "brain/data/Settings.inc.php";
|
2020-11-17 23:27:25 +01:00
|
|
|
|
|
|
|
class Auth
|
|
|
|
{
|
2021-03-25 22:05:32 +01:00
|
|
|
private $configs;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sessionStatus()
|
|
|
|
{
|
|
|
|
if (isset($_SESSION["member"])) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//return $this->secret;
|
|
|
|
}
|
2021-03-27 21:59:44 +01:00
|
|
|
|
|
|
|
public function login($who)
|
|
|
|
{
|
|
|
|
//grab member list
|
|
|
|
$folks = (new Settings())->getFolks();
|
|
|
|
$found = find($folks, ["handle" => $who["handle"]]);
|
|
|
|
|
|
|
|
if ($found) {
|
|
|
|
//name is found, verify password
|
|
|
|
if (password_verify($who["password"], $found["password"])) {
|
|
|
|
$result = [
|
|
|
|
"message" => "Welcome back",
|
|
|
|
"type" => "TASK_LOGIN",
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
$result = [
|
|
|
|
"message" => "Check your password, sport",
|
|
|
|
"type" => "TASK_LOGIN",
|
|
|
|
];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//if name is not found
|
|
|
|
$result = [
|
|
|
|
"message" => "Need to see some id, champ",
|
|
|
|
"type" => "TASK_LOGIN",
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
2021-03-25 22:05:32 +01:00
|
|
|
}
|