D
D
dilshod_developer2016-04-13 09:52:26
Yii
dilshod_developer, 2016-04-13 09:52:26

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

1 answer(s)
R
rahimmuratov, 2016-04-13
@rahimmuratov

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()
{
//здесь логиним пользователя
}

Registration & Authentication in yii2 . All the best!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question