diff options
| author | 2014-10-07 10:16:38 +0200 | |
|---|---|---|
| committer | 2014-10-07 10:16:38 +0200 | |
| commit | 6009990935a2d06c252073f6b51ea5378536ef52 (patch) | |
| tree | f4d9505b63585697599b8d99b03b8d555f638aa7 /app/Models/Auth.php | |
| parent | 79aa5beaf44af13a1828bfa5fc824a08c62054dc (diff) | |
Introduce FreshRSS_Auth::hasAccess('admin')
Replace Minz_Configuration::isAdmin($user). FreshRSS_Auth::hasAccess() could
be extended to others scopes later.
See https://github.com/marienfressinaud/FreshRSS/issues/655
Diffstat (limited to 'app/Models/Auth.php')
| -rw-r--r-- | app/Models/Auth.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/Models/Auth.php b/app/Models/Auth.php index c4a3abd98..992b444a5 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -99,12 +99,23 @@ class FreshRSS_Auth { } /** - * Returns if current user is connected. + * Returns if current user has access to the given scope. * - * @return boolean true if user is connected, false else. + * @param string $scope general (default) or admin + * @return boolean true if user has corresponding access, false else. */ - public static function hasAccess() { - return self::$login_ok; + public static function hasAccess($scope = 'general') { + $ok = self::$login_ok; + switch ($scope) { + case 'general': + break; + case 'admin': + $ok &= Minz_Session::param('currentUser') === Minz_Configuration::defaultUser(); + break; + default: + $ok = false; + } + return $ok; } /** |
