Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit f3c94cb

Browse files
author
Jamie Snape
committed
Add a helper function to check whether a user is logged in
1 parent 40785c7 commit f3c94cb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/AppController.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,17 +511,29 @@ public function requireAjaxRequest()
511511
}
512512

513513
/**
514-
* Ensure that the user is logged in and has admin privileges.
514+
* Ensure that a user is logged in and has admin privileges.
515515
*
516516
* @throws Zend_Exception
517517
*/
518518
public function requireAdminPrivileges()
519519
{
520-
if (!$this->logged || !$this->userSession->Dao->getAdmin() == 1) {
520+
if ($this->logged === false || $this->userSession->Dao->getAdmin() != 1) {
521521
throw new Zend_Exception(MIDAS_ADMIN_PRIVILEGES_REQUIRED, 403);
522522
}
523523
}
524524

525+
/**
526+
* Ensure that a user is logged in.
527+
*
528+
* @throws Zend_Exception
529+
*/
530+
public function requireUserPrivileges()
531+
{
532+
if ($this->logged === false) {
533+
throw new Zend_Exception(MIDAS_LOGIN_REQUIRED, 403);
534+
}
535+
}
536+
525537
/**
526538
* Return the translation of a given string.
527539
*

0 commit comments

Comments
 (0)