Skip to content

Commit

Permalink
add check_authenticated method to user class
Browse files Browse the repository at this point in the history
  • Loading branch information
brookgagnon committed Sep 13, 2024
1 parent 2936352 commit 1b37441
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion classes/core/obfuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 1b37441

Please sign in to comment.