fipamo/brain/data/Auth.inc.php

53 lines
1,021 B
PHP

<?php
use function _\find;
include "brain/data/Settings.inc.php";
class Auth
{
private $configs;
public function __construct()
{
}
public function sessionStatus()
{
if (isset($_SESSION["member"])) {
return true;
} else {
return false;
}
//return $this->secret;
}
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;
}
}