我正在尝试检查权限级别,但唯一有效的功能是Int...
,当func sumOf(numbers: Int...) -> Int {
var sum = 0
for number in numbers {
sum += number
}
return sum
}
sumOf()
sumOf(42, 597, 12)
,auth.perm_one
等相同时..用户具有权限级别数据库中的10个。
我已在下面发布了所有相关代码。
中间件文件:
perm_two
用户文件:
perm_three
我试图实现这个目标:
<?php
namespace BSA\Middleware;
use Slim\Middleware;
class BeforeMiddleware extends Middleware
{
public function call()
{
$this->app->hook('slim.before', [$this, 'run']);
$this->next->call();
}
public function run()
{
if (isset($_SESSION[$this->app->config->get('auth.session')])){
$this->app->auth = $this->app->user->where('id', $_SESSION[$this->app->config->get('auth.session')])->first();
}
$this->app->view()->appendData([
'auth' => $this->app->auth,
'baseUrl' => $this->app->config->get('app.url')
]);
}
}
答案 0 :(得分:1)
我明白了。以下是受影响函数的新代码:
public function hasPermission($permission)
{
$perm_level = intval($this->perm_level);
$permission = $permission - 1;
if ($perm_level > $permission) {return true;} else {return false;}
}