[英]Yii2 stateKeyPrefix for frontend and backend login
我想從不同的表中使用不同的憑據登錄前端和后端,所以我現在有不同的表單、模型、規則等......
我嘗試將stateKeyPrefix
設置為 Yii,但它不起作用。
有人知道如何登錄嗎?
以下方法返回true,因為我已經在前端登錄了n;
public function actionLogin() {
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginAdminForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
您應該在用戶配置中定義 stateKeyPrefix:
'user'=>array(
'stateKeyPrefix'=>'yourDifferentPrefixForEveryDomain',
...
),
和會話組件中的不同 sessionName:
'session' => array (
'sessionName' => 'differentSessionNameForEveryDomain',
...
),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.