|
|
@@ -38,6 +38,11 @@ class BaseController extends \yii\rest\ActiveController {
|
|
|
public function beforeAction($action) {
|
|
|
$parentBeforeAction = parent::beforeAction($action);
|
|
|
|
|
|
+ // 动态返回语言:zh-CN | en-US
|
|
|
+ if (!Yii::$app->request->isOptions) {
|
|
|
+ Yii::$app->language = Yii::$app->request->headers->get('language') ?? 'zh-CN';
|
|
|
+ Yii::$app->sourceLanguage = (Yii::$app->request->headers->get('language') ?? 'zh-CN') == 'zh-CN' ? 'en-US' : 'zh-CN';
|
|
|
+ }
|
|
|
// 增加的判断用户登录后未操作后的超时
|
|
|
if (Yii::$app->getUser()->getUserInfo()){
|
|
|
$adminId = Yii::$app->getUser()->getUserInfo()['id'];
|
|
|
@@ -53,7 +58,8 @@ class BaseController extends \yii\rest\ActiveController {
|
|
|
$currentTime = time();
|
|
|
$timeOut = Yii::$app->params['operationTimeOut'];
|
|
|
if ($currentTime - $lastTime > $timeOut) {
|
|
|
- return self::notice('Connection not operated for too long', 402);
|
|
|
+
|
|
|
+ return self::notice(Yii::t('ctx', 'notConnection'), 402);
|
|
|
} else {
|
|
|
Yii::$app->tokenRedis->hset($redisKey, $adminId, time());
|
|
|
}
|
|
|
@@ -68,24 +74,18 @@ class BaseController extends \yii\rest\ActiveController {
|
|
|
$menu = require Yii::getAlias('@backendApi/config/menu.php');// 获取此页面code,对应的权限值
|
|
|
$pagePermission = $this->checkPagePermission($sqlCode, $menu);
|
|
|
if (empty($pagePermission)) {
|
|
|
- return self::notice('Insufficient user permissions', 403);
|
|
|
+ return self::notice(Yii::t('ctx', 'noPermission'), 403);
|
|
|
}
|
|
|
if(!Yii::$app->user->validateAdminAction($pagePermission['controller'], $pagePermission['action'])) {
|
|
|
|
|
|
- return self::notice('Insufficient user permissions', 403);
|
|
|
+ return self::notice(Yii::t('ctx', 'noPermission'), 403);
|
|
|
} else {
|
|
|
|
|
|
return $parentBeforeAction;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return self::notice('Insufficient user permissions', 403);
|
|
|
- }
|
|
|
-
|
|
|
- // 动态返回语言:zh-CN | en-US
|
|
|
- if (!Yii::$app->request->isOptions) {
|
|
|
- Yii::$app->language = Yii::$app->request->headers->get('language') ?? 'zh-CN';
|
|
|
- Yii::$app->sourceLanguage = (Yii::$app->request->headers->get('language') ?? 'zh-CN') == 'zh-CN' ? 'en-US' : 'zh-CN';
|
|
|
+ return self::notice(Yii::t('ctx', 'noPermission'), 403);
|
|
|
}
|
|
|
|
|
|
return $parentBeforeAction;
|