aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Auth.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-05 23:26:38 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-05 23:26:38 +0200
commit2118448133e327294ad2b69ed8736bc29879103d (patch)
tree00c003056dedbd8e3554801d6493a25641a260a5 /app/Models/Auth.php
parent4f078958b5603900592e14f9f3189bbebfc81bab (diff)
PHPStan level 6 for more files (#5264)
7 more files passing (see phpstan-next.txt)
Diffstat (limited to 'app/Models/Auth.php')
-rw-r--r--app/Models/Auth.php22
1 files changed, 12 insertions, 10 deletions
diff --git a/app/Models/Auth.php b/app/Models/Auth.php
index 65e761fb8..ccf244033 100644
--- a/app/Models/Auth.php
+++ b/app/Models/Auth.php
@@ -9,12 +9,13 @@ class FreshRSS_Auth {
*/
const DEFAULT_COOKIE_DURATION = 7776000;
+ /** @var bool */
private static $login_ok = false;
/**
* This method initializes authentication system.
*/
- public static function init() {
+ public static function init(): bool {
if (isset($_SESSION['REMOTE_USER']) && $_SESSION['REMOTE_USER'] !== httpAuthUser()) {
//HTTP REMOTE_USER has changed
self::removeAccess();
@@ -47,9 +48,9 @@ class FreshRSS_Auth {
* Required session parameters are also set in this method (such as
* currentUser).
*
- * @return boolean true if user can be connected, false else.
+ * @return bool true if user can be connected, false otherwise.
*/
- private static function accessControl() {
+ private static function accessControl(): bool {
$auth_type = FreshRSS_Context::$system_conf->auth_type;
switch ($auth_type) {
case 'form':
@@ -100,7 +101,7 @@ class FreshRSS_Auth {
/**
* Gives access to the current user.
*/
- public static function giveAccess() {
+ public static function giveAccess(): bool {
FreshRSS_Context::initUser();
if (FreshRSS_Context::$user_conf == null) {
self::$login_ok = false;
@@ -136,7 +137,7 @@ class FreshRSS_Auth {
* @param string $scope general (default) or admin
* @return boolean true if user has corresponding access, false else.
*/
- public static function hasAccess($scope = 'general') {
+ public static function hasAccess($scope = 'general'): bool {
if (FreshRSS_Context::$user_conf == null) {
return false;
}
@@ -159,7 +160,7 @@ class FreshRSS_Auth {
/**
* Removes all accesses for the current user.
*/
- public static function removeAccess() {
+ public static function removeAccess(): void {
self::$login_ok = false;
Minz_Session::_params([
'loginOk' => false,
@@ -200,18 +201,18 @@ class FreshRSS_Auth {
/**
* Return if authentication is enabled on this instance of FRSS.
*/
- public static function accessNeedsLogin() {
+ public static function accessNeedsLogin(): bool {
return FreshRSS_Context::$system_conf->auth_type !== 'none';
}
/**
* Return if authentication requires a PHP action.
*/
- public static function accessNeedsAction() {
+ public static function accessNeedsAction(): bool {
return FreshRSS_Context::$system_conf->auth_type === 'form';
}
- public static function csrfToken() {
+ public static function csrfToken(): string {
$csrf = Minz_Session::param('csrf');
if ($csrf == '') {
$salt = FreshRSS_Context::$system_conf->salt;
@@ -220,7 +221,8 @@ class FreshRSS_Auth {
}
return $csrf;
}
- public static function isCsrfOk($token = null) {
+
+ public static function isCsrfOk(?string $token = null): bool {
$csrf = Minz_Session::param('csrf');
if ($token === null) {
$token = $_POST['_csrf'] ?? '';