Help us understand the problem. What is going on with this article?

FuelPHP 1.5 で oil generate admin... すると無限ループになるかもに暫定対処する

More than 5 years have passed since last update.

FuelPHP 1.5 で oil generate admin... すると無限ループになるかもに暫定対処する

FuelPHP 1.5 で

$ oil generate admin...

を実行すると、認証部分で無限ループになるかも。

そんな時は以下を参考に対処すると良いかも知れん。

http://fuelphp.com/forums/discussion/11811/using-oil-to-generate-admin-panel-problem/p1

https://github.com/fuel/oil/commit/1b334d1160736846fe7a3bdc4e3ca5e9fb1abb16

oil 側を修正することで oil g admin しても大丈夫になるようにする。

以下の2ファイルを各々、以下の内容に修正する事で、oil g admin した時に生成されるファイルにおいて、無限ループに陥らないようになる。

/fuel/packages/oil/views/admin/crud/controllers/admin.php
    public function before()
    {
        parent::before();

        if (Request::active()->controller !== 'Controller_Admin' or ! in_array(Request::active()->action, array('login', 'logout')))
        {
            if (Auth::check())
            {
                if ( ! Auth::member(100))
                {
                    Session::set_flash('error', e('You don\'t have access to the admin panel'));
                    Response::redirect('/');
                }
            }
            else
            {
                Response::redirect('admin/login');
            }
        }
    }
/fuel/packages/oil/views/admin/orm/controllers/admin.php
    public function before()
    {
        parent::before();

        if (Request::active()->controller !== 'Controller_Admin' or ! in_array(Request::active()->action, array('login', 'logout')))
        {
            if (Auth::check())
            {
                if ( ! Auth::member(100))
                {
                    Session::set_flash('error', e('You don\'t have access to the admin panel'));
                    Response::redirect('/');
                }
            }
            else
            {
                Response::redirect('admin/login');
            }
        }
    }

もう既に oil g admin してしまっていて、とりあえずApp側だけ修正する場合

もう既に oil g admin してしまっていて、とりあえずApp側だけ修正したいんだけど…
という場合は以下の内容に書き換えればOKなはず。

/fuel/app/classes/controller/admin.php
    public function before()
    {
        parent::before();

        if (Request::active()->controller !== 'Controller_Admin' or ! in_array(Request::active()->action, array('login', 'logout')))
        {
            if (Auth::check())
            {
                if ( ! Auth::member(100))
                {
                    Session::set_flash('error', e('You don\'t have access to the admin panel'));
                    Response::redirect('/');
                }
            }
            else
            {
                Response::redirect('admin/login');
            }
        }
    }

上記にすることで、oil g admin で生成されたファイルの無限ループには暫定対応可能なはず。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした