D
D
djienbaev972020-04-21 20:22:07
Yii
djienbaev97, 2020-04-21 20:22:07

The site has redirected too many times, how to solve?

Hello! I'm using advanced version of yii2 and /admin has an admin login form. And I added the admin column with the values ​​0 and 1 in the user table. Now I

put the following check in the controller

public function actionIndex()
    {
        if (Yii::$app->user->isGuest || Yii::$app->user->identity->admin!=1) {
            return $this->redirect('/admin/site/login');
        }
        return $this->render('index');
    }


If I enter my username and password correctly when logging in. but this user has admin=0 then I come across this page: Page not available The site abc redirected too many times.
Delete cookies..
ERR_TOO_MANY_REDIRECTS

Only after clearing the cache can I enter my password and login back, how can I solve this? From what redirection is done many times?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-04-22
@djienbaev97

You have a problem with multiple redirects. I assume that this index is your main page. And in the controller /admin/site/loginyou have a redirect to goHome(). What is the result? You get to the main page, you are redirected to the login, the login redirects to the home page. And here is your cycle. I suspect it is

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question