From 1b37441e50e4b139e2dcd22c66bd2b98e6f87880 Mon Sep 17 00:00:00 2001 From: Brook Gagnon Date: Fri, 13 Sep 2024 18:15:14 +0000 Subject: [PATCH] add check_authenticated method to user class --- classes/core/obfuser.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/core/obfuser.php b/classes/core/obfuser.php index d90cd84..88b084a 100644 --- a/classes/core/obfuser.php +++ b/classes/core/obfuser.php @@ -391,13 +391,21 @@ public function param($param) return false; } + /** + * Check if the user is currently authenticated. + */ + public function check_authenticated() + { + return $this->param('id') != 0; + } + /** * Function to put on top of controller methods that require authentication. * This throws an error and kills the call if no user is logged in. */ public function require_authenticated() { - if ($this->param('id') == 0) { + if (!$this->check_authenticated()) { $this->io->error(OB_ERROR_DENIED); die(); }