diff --git a/lib/Session.php b/lib/Session.php index aa3f70a5..b11a4d94 100644 --- a/lib/Session.php +++ b/lib/Session.php @@ -37,12 +37,14 @@ class Session{ // ******* /** + * @param ?string $identifier Either the email, or the UUID, of the user attempting to log in. + * * @throws Exceptions\InvalidLoginException * @throws Exceptions\PasswordRequiredException */ - public function Create(?string $email = null, ?string $password = null): void{ + public function Create(?string $identifier = null, ?string $password = null): void{ try{ - $this->User = User::GetIfRegistered($email, $password); + $this->User = User::GetIfRegistered($identifier, $password); $this->UserId = $this->User->UserId; $existingSessions = Db::Query(' diff --git a/lib/User.php b/lib/User.php index 39fc23fd..1ae71ad5 100644 --- a/lib/User.php +++ b/lib/User.php @@ -1,5 +1,4 @@ PasswordHash !== null && $password === null){ + if($user->PasswordHash !== null && $password === null){ // Indicate that a password is required before we log in throw new Exceptions\PasswordRequiredException(); } - if($result[0]->PasswordHash !== null && !password_verify($password ?? '', $result[0]->PasswordHash)){ + if($user->PasswordHash !== null && !password_verify($password ?? '', $user->PasswordHash)){ throw new Exceptions\UserNotFoundException(); } - return $result[0]; + return $user; } }