From fea439b57f9ba225e2d3169d7615c0bd2aecabe4 Mon Sep 17 00:00:00 2001 From: winter Date: Wed, 1 Jan 2025 19:52:18 +0000 Subject: ultra basic post form doesn't do much but i just wanted to get this working at a bare minimum --- Digitigrade/Model/UserAccount.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Digitigrade') diff --git a/Digitigrade/Model/UserAccount.php b/Digitigrade/Model/UserAccount.php index 3d0e2a4..72a9ce9 100644 --- a/Digitigrade/Model/UserAccount.php +++ b/Digitigrade/Model/UserAccount.php @@ -1,6 +1,7 @@ userAccount; } + /** + * Gets the currently logged-in user account, or throws an error + * @throws Unauthorized if no account could be found + */ + public static function requireByCurrentSession(): self { + $user = self::findByCurrentSession(); + if ($user == null) { + throw new Unauthorized(); + } + return $user; + } + public function verifyPassword(#[\SensitiveParameter] $attemptedPassword): bool { return password_verify($attemptedPassword, $this->passwordHash); } -- cgit v1.3