|
@@ -1,48 +0,0 @@
|
|
|
-<?php
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | [ WE CAN DO IT MORE SIMPLE ]
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | Copyright (c) 2018-2020 rights reserved.
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | Author: TABLE ME
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | Date: 2020-08-30 14:59
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-namespace app\admin\middleware;
|
|
|
-
|
|
|
-use app\model\admin\Site;
|
|
|
-use app\Request;
|
|
|
-use library\exceptions\AuthException;
|
|
|
-use library\interfaces\MiddlewareInterface;
|
|
|
-
|
|
|
-class SeretKeyMiddleware implements MiddlewareInterface
|
|
|
-{
|
|
|
- public function handle(Request $request, \Closure $next)
|
|
|
- {
|
|
|
- $secret_key =$request->header('SECRET-KEY');
|
|
|
- $request->site = $this->checkSecret($secret_key);
|
|
|
- return $next($request);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 检查数据是否正常
|
|
|
- * @param $secret_key
|
|
|
- */
|
|
|
- private function checkSecret($secret_key) {
|
|
|
- if(empty($secret_key)) {
|
|
|
- throw new AuthException('当前站点已经不存在,暂无法登陆', -100);
|
|
|
- }
|
|
|
- $siteData = (new Site)->where('secret_key',$secret_key)->find();
|
|
|
- if(empty($siteData)) {
|
|
|
- throw new AuthException('当前站点已经不存在,暂无法登陆', -100);
|
|
|
- }
|
|
|
- //站点停用
|
|
|
- if(empty($siteData['status'])) {
|
|
|
- throw new AuthException('抱歉,前站点已经停用。', -100);
|
|
|
- }
|
|
|
- return $siteData->toArray();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|