问题描述
我要使特定类型的用途在一定时间后退出,其他应保持登录状态直到手动退出 之前
$rules = $request->validate([
'game_id' => 'required|exists:games,id','team1_id' => 'required|exists:teams,id|in:games,'team2_id' => 'required|exists:teams,]);
以及下面的webUser.php
'user' => [
'class' => app\components\WebUser::class,'identityClass' => app\modules\ecosmob\auth\models\UserMaster::class,'enableAutoLogin' => false,'loginUrl' => ['/auth/auth/login']
]
main.php
public function init()
{
parent::init();
$authTimeout = (new Query())
->select('gwc_value')
->from('global_web_config')
->where('gwc_key = :gwc_key',['gwc_key' => 'session_timeout'])
->scalar();
if ($authTimeout) {
$this->authTimeout = ($authTimeout * 60) - 5;
} else {
$this->authTimeout = AUTH_TIMEOUT_DYNAMIC;
}
}
我强烈要求它恢复功能并为所有用户进行自动登录,并使用登录持续时间使某些类型的用户退出,但无法按以下方式工作
Yii::$app->view->registerMetaTag(['http-equiv' => 'refresh','content' => Yii::$app->user->authTimeout + 5]);
和登录模式下
'user' => [
'class' => app\components\WebUser::class,'enableAutoLogin' => true,'loginUrl' => ['/auth/auth/login'],'enableSession'=>true
],
解决方法
可能有不同的解决方案,但是我想到的第一个解决方案是对EVENT_BEFORE_LOGOUT
事件做出反应。您可以在此处检查是否要注销用户,并让注销过程完成(或不完成)。选中yii\web\User::beforeLogout