Answer the question
In order to leave comments, you need to log in
Organization of authorization mechanism in yii2?
Good afternoon.
How in yii2 to do so if the user is not authorized redirect to the authorization page.
I am using the standard yii2 authorization mechanism.
Answer the question
In order to leave comments, you need to log in
Hey! To do this, you need to check. For example
public function actionProfile()
{
//Страница профиля
//если пользователь не авторизован то перенаправляем его на страницу логина
if(Yii::$app()->user->isGuest)
{
return $this->redirect(['login']);
}
//здесь пишем продолжение...
}
public function actionLogin()
{
//здесь логиним пользователя
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question