frontend and backend login problem

hi there

i copied common\models\loginform and common\models\user to backend and modified this:

public static function findIdentity($id)


    return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE, 'role' => 10]);


the problem is when i log in from backend and then log out, and go to frontend and do a success log in, after log in it route me to backend/login and i have to press back button to go to frontend again

what should i do?


that problem solved by this way:

 public function actionLogin()



        if (!\Yii::$app->user->isGuest) {

//            return $this->goHome();

            return $this->redirect(Url::to(['site/index']));


        $model = new LoginForm();

        if ($model->load(Yii::$app->request->post()) && $model->login()) {

            //return $this->goBack();

            return $this->redirect(Url::to(['site/index']));

        } else {

            return $this->render('login', [

                'model' => $model,




a problem is that, when i logged in in frontend, do a refresh in backend, then go to frontend and try to log out, at the first time it show me this error:

and if try to log out again, it will be log out with out error:

log out link is this:

<a data-method="post" href="<?= Url::to(['/site/logout']]) ?>" class="btn btn-default btn-flat">خروج</a>

and i think the problem is for data-method="post"

thanks in advanced