修复:酒道馆token过期后未正常处理,导致用户登录状态也被删除了。
This commit is contained in:
parent
1310ea97b1
commit
045fb46855
|
|
@ -32,13 +32,13 @@ class ShopTokenMiddleware extends BaseMiddleware{
|
|||
$repository->checkToken($token);
|
||||
$payload = $service->decode($token);
|
||||
} catch (Throwable $e) {//Token 过期
|
||||
throw new AuthException('token 已过期');
|
||||
throw new ValidateException('token 已过期');
|
||||
}
|
||||
if ('mer' != $payload->jti[1]) throw new AuthException('无效的 token');
|
||||
if ('mer' != $payload->jti[1]) throw new ValidateException('无效的 token');
|
||||
|
||||
$admin = $repository->get($payload->jti[0]);
|
||||
if (!$admin) throw new AuthException('账号不存在');
|
||||
if (!$admin['status']) throw new AuthException('账号已被禁用');
|
||||
if (!$admin) throw new ValidateException('账号不存在');
|
||||
if (!$admin['status']) throw new ValidateException('账号已被禁用');
|
||||
|
||||
/**
|
||||
* @var MerchantRepository $merchantRepository
|
||||
|
|
@ -48,7 +48,7 @@ class ShopTokenMiddleware extends BaseMiddleware{
|
|||
$merchant = $merchantRepository->get($admin->mer_id);
|
||||
|
||||
if (!$merchant || !$merchant['status'])
|
||||
throw new AuthException('商户已被锁定');
|
||||
throw new ValidateException('商户已被锁定');
|
||||
|
||||
} catch (Throwable $e) {
|
||||
if ($force) throw $e;
|
||||
|
|
@ -56,7 +56,7 @@ class ShopTokenMiddleware extends BaseMiddleware{
|
|||
return false;
|
||||
});
|
||||
$request->macros(['merchantType', 'shopMerId'], function () {
|
||||
throw new AuthException('请登录');
|
||||
throw new ValidateException('请登录');
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,11 +239,9 @@ class MerchantAdminRepository extends BaseRepository
|
|||
public function checkToken(string $token)
|
||||
{
|
||||
$has = Cache::has('mer_' . $token);
|
||||
if (!$has)
|
||||
throw new AuthException('无效的token');
|
||||
if (!$has) throw new ValidateException('token 已经失效,请重新登录!');
|
||||
$lastTime = Cache::get('mer_' . $token);
|
||||
if (($lastTime + (intval(Config::get('admin.token_valid_exp', 15))) * 60) < time())
|
||||
throw new AuthException('token 已过期');
|
||||
if (($lastTime + (intval(Config::get('admin.token_valid_exp', 15))) * 60) < time()) throw new ValidateException('token 已过期');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class Merchant extends BaseController
|
|||
|
||||
return app('json')->success([
|
||||
'token' => $tokenInfo['token'],
|
||||
'exp' => $tokenInfo['out'],
|
||||
'exp' => $tokenInfo['exp'],
|
||||
'mer_id' => $admin['mer_id'],
|
||||
'merchant_type' => $admin['merchant_type'],
|
||||
'mer_name' => $admin['mer_name'],
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
return [
|
||||
//token 有效期
|
||||
'token_exp' => 6, //6小时
|
||||
'token_exp' => 24, //6小时
|
||||
//token超时多久可自动续期(后台)
|
||||
'token_valid_exp' => 30, //30分钟
|
||||
//token超时多久可自动续期(用户)
|
||||
|
|
|
|||
Loading…
Reference in New Issue