Add Authenticator::verifyCredentials to verify credentials without logging in

This commit is contained in:
Jill Stingray 2020-07-29 11:01:37 +00:00
parent 4adcf433c5
commit 55515de8b6

View file

@ -86,7 +86,7 @@ class Authenticator
$this->session->set("tok", $this->makeToken($user, CONNECTING_IP, $_SERVER["HTTP_USER_AGENT"])); $this->session->set("tok", $this->makeToken($user, CONNECTING_IP, $_SERVER["HTTP_USER_AGENT"]));
} }
function login(string $id, string $password): bool function verifyCredentials(string $id, string $password): bool
{ {
$user = $this->db->table("ChandlerUsers")->get($id); $user = $this->db->table("ChandlerUsers")->get($id);
if(!$user) if(!$user)
@ -94,6 +94,14 @@ class Authenticator
else if(!$this->verifyHash($password, $user->passwordHash)) else if(!$this->verifyHash($password, $user->passwordHash))
return false; return false;
return true;
}
function login(string $id, string $password): bool
{
if(!$this->verifyCredentials($id, $password))
return false;
$this->authenticate($id); $this->authenticate($id);
return true; return true;
} }