PHP code example of 5ini99 / think-auth
1. Go to this page and download the library: Download 5ini99/think-auth library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
5ini99 / think-auth example snippets
use think\Controller;
use think\auth\Auth;
class Base extends Controller
{
public function _initialize()
{
$controller = request()->controller();
$action = request()->action();
$auth = new Auth();
if(!$auth->check($controller . '-' . $action, session('uid'))){
$this->error('你没有权限访问');
}
}
}
$auth->check('rule1,rule2',uid);