Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d99e168583 | ||
|
|
d6bb1456fa | ||
|
|
91eac36371 | ||
|
|
1e4486989a | ||
|
|
f9f25b76dd | ||
|
|
7603cdfa7e | ||
|
|
2e0cc85966 | ||
|
|
5814fed0da | ||
|
|
40f7ee82cd | ||
|
|
936cb56c7f | ||
|
|
2d1940522c | ||
|
|
264cf56ae4 |
@@ -14,7 +14,7 @@ use think\Response;
|
|||||||
class Login extends AdminController
|
class Login extends AdminController
|
||||||
{
|
{
|
||||||
|
|
||||||
protected bool $ignoreAuth = true;
|
protected bool $ignoreLogin = true;
|
||||||
|
|
||||||
public function initialize(): void
|
public function initialize(): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace app\admin\controller\mall;
|
|||||||
|
|
||||||
use app\admin\model\MallCate;
|
use app\admin\model\MallCate;
|
||||||
use app\admin\model\MallGoods;
|
use app\admin\model\MallGoods;
|
||||||
|
use app\admin\service\annotation\MiddlewareAnnotation;
|
||||||
use app\common\controller\AdminController;
|
use app\common\controller\AdminController;
|
||||||
use app\admin\service\annotation\ControllerAnnotation;
|
use app\admin\service\annotation\ControllerAnnotation;
|
||||||
use app\admin\service\annotation\NodeAnnotation;
|
use app\admin\service\annotation\NodeAnnotation;
|
||||||
@@ -66,4 +67,9 @@ class Goods extends AdminController
|
|||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[MiddlewareAnnotation(ignore: MiddlewareAnnotation::IGNORE_LOGIN)]
|
||||||
|
public function no_check_login(Request $request): string
|
||||||
|
{
|
||||||
|
return '这里演示方法不需要经过登录验证';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ use app\Request;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use app\admin\service\annotation\MiddlewareAnnotation;
|
||||||
|
|
||||||
class CheckLogin
|
class CheckLogin
|
||||||
{
|
{
|
||||||
@@ -24,13 +25,22 @@ class CheckLogin
|
|||||||
$controllerClass = 'app\\admin\\controller\\' . $controller;
|
$controllerClass = 'app\\admin\\controller\\' . $controller;
|
||||||
$classObj = new ReflectionClass($controllerClass);
|
$classObj = new ReflectionClass($controllerClass);
|
||||||
$properties = $classObj->getDefaultProperties();
|
$properties = $classObj->getDefaultProperties();
|
||||||
$ignoreAuth = $properties['ignoreAuth'] ?? false;
|
// 整个控制器是否忽略登录
|
||||||
$adminUserInfo = session('admin');
|
$ignoreLogin = $properties['ignoreLogin'] ?? false;
|
||||||
if (!$ignoreAuth) {
|
$adminUserInfo = session('admin');
|
||||||
|
if (!$ignoreLogin) {
|
||||||
$noNeedCheck = $properties['noNeedCheck'] ?? [];
|
$noNeedCheck = $properties['noNeedCheck'] ?? [];
|
||||||
if (in_array($action, $noNeedCheck)) {
|
if (in_array($action, $noNeedCheck)) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
$reflectionMethod = new \ReflectionMethod($controllerClass, $action);
|
||||||
|
$attributes = $reflectionMethod->getAttributes(MiddlewareAnnotation::class);
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
$annotation = $attribute->newInstance();
|
||||||
|
$_ignore = (array)$annotation->ignore;
|
||||||
|
// 控制器中的某个方法忽略登录
|
||||||
|
if (in_array('LOGIN', $_ignore)) return $next($request);
|
||||||
|
}
|
||||||
if (empty($adminUserInfo)) {
|
if (empty($adminUserInfo)) {
|
||||||
return redirect(__url('login/index'));
|
return redirect(__url('login/index'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ final class MiddlewareAnnotation
|
|||||||
/** 过滤日志 */
|
/** 过滤日志 */
|
||||||
const IGNORE_LOG = 'LOG';
|
const IGNORE_LOG = 'LOG';
|
||||||
|
|
||||||
|
/** 免登录 */
|
||||||
|
const IGNORE_LOGIN = 'LOGIN';
|
||||||
|
|
||||||
public function __construct(public string $type = '', public string|array $ignore = '')
|
public function __construct(public string $type = '', public string|array $ignore = '')
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ class AdminController extends BaseController
|
|||||||
'version' => env('APP_DEBUG') ? time() : ConfigService::getVersion(),
|
'version' => env('APP_DEBUG') ? time() : ConfigService::getVersion(),
|
||||||
'adminUploadUrl' => url('ajax/upload', [], false),
|
'adminUploadUrl' => url('ajax/upload', [], false),
|
||||||
'adminEditor' => sysConfig('site', 'editor_type') ?: 'wangEditor',
|
'adminEditor' => sysConfig('site', 'editor_type') ?: 'wangEditor',
|
||||||
'iframeOpenTop' => sysConfig('site', 'iframe_open_top') ?: 0,
|
'iframeOpenTop' => sysConfig('site', 'iframe_open_top') ?: 0,
|
||||||
];
|
];
|
||||||
View::assign($data);
|
View::assign($data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Install extends BaseController
|
|||||||
];
|
];
|
||||||
$currentHost = '://';
|
$currentHost = '://';
|
||||||
$result = compact('errorInfo', 'currentHost', 'isInstall', 'envInfo');
|
$result = compact('errorInfo', 'currentHost', 'isInstall', 'envInfo');
|
||||||
return view('index/install/index', $result);
|
return view('index@install/index', $result);
|
||||||
}
|
}
|
||||||
if ($errorInfo) $this->error($errorInfo);
|
if ($errorInfo) $this->error($errorInfo);
|
||||||
$charset = 'utf8mb4';
|
$charset = 'utf8mb4';
|
||||||
|
|||||||
@@ -516,4 +516,5 @@ table样式
|
|||||||
|
|
||||||
.wangEditor_div {
|
.wangEditor_div {
|
||||||
z-index: 99999;
|
z-index: 99999;
|
||||||
|
border: 1px solid var(--w-e-textarea-slight-border-color);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user