From 302b3347792ba6870bc9926d3d1ed66043c3198f Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Wed, 24 Aug 2022 01:01:55 +0800 Subject: [PATCH] user_can() throw exception when no authentication --- include/globalfunctions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/globalfunctions.php b/include/globalfunctions.php index b381c1e2..c48627f2 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -1006,8 +1006,7 @@ function user_can($permission, $fail = false, $uid = 0, $class = null): bool $log .= ", set current uid: $uid"; } if ($uid <= 0) { - do_log("$log, no uid, false", 'error'); - return false; + throw new \RuntimeException("No authentication info !"); } if (!$fail && isset($userCanCached[$permission][$uid])) { return $userCanCached[$permission][$uid];