Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing Problem: endless loop
  • Hi,

    I try to build a Login with separated Front- and Backend from the scratch.

    Frontent is working perfectly, but when I try to access the Backend I have an endless loop.

    Idea for separation and the needed routing comes from here:
    http://www.marcopace.it/blog/2012/11/fuelphp-separation-between-back-end-and-front-end

    Login (Ormauth) from here: http://fuelphp.com/dev-docs/packages/auth/examples/auth.html

    I have separated the login function into another controller which extends the Private controller, but still no luck.

    Here is my code:

    Controller_Private: http://bin.fuelphp.com/snippet/view/q8
    Controller_Private_User: http://bin.fuelphp.com/snippet/view/q9
    Routes: http://bin.fuelphp.com/snippet/view/q-

    /admin goes to /admin/login and has an endless loop
    /private/user/login goes to /admin/login and has an endless loop

    I have no idea why this happenz. Hope someone could shed a little bit light on this.

    Thanks
    Kay

  • Using oil admin scaffolding?

    There was a bug there, but it was solved quite some time ago.
  • No, copied from the Blog and the docs section.
    Just installed fresh v1.6.1
  • HarroHarro
    Accepted Answer
    I think the problem may be this code, in your controllers' before method:

            // User isn't logged in
            if(!\Auth::check())   
            {
                \Session::set_flash('error', 'User isn\'t logged in!');
                   \Debug::dump(\Auth::check()); #die;
                \Response::redirect('admin/login');
            }

    Assuming that admin/login points to a method in this controller too, it hits this code, redirects to login, but then hit this code again, before it gets to your login action.

    It should not redirect here if the action called is "login".
  • Understood, but in my opinion it makes Sense to Check if the User is Not loggend in and then send him to the Login of the backend System, or?

    Should I make the Login in the public area, so that this is Not in the private Controller? Or what would you suggest me to do?
  • Yes, but you shouldn't check on the way to the login, your login action should be publicly available, since Auth::check() should return false in the case of login (you're not logged in yet).
  • I do Login and Logout now in the Public Main controller and it works.
    Thanks Harry... as always

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion