FatFree basic auth, reroute on cancel

334 views Asked by At

How to make FatFree reroute to whatever page I want it to, if user clicks on CANCEL button, when basic auth dialog appears?

I tried with -

if (! $auth->basic()){
   $this->f3->reroute('/');
}

but this doesn't work. Page is shown with message:

Unauthorized

HTTP 401 (GET /protected-url)
1

There are 1 answers

0
user2984700 On

reroute in the $f3 bootstrap index.php can be used like this:

  //logoutfrom forum
    $f3->route('GET    /logout',
    function($f3)
        {
         $f3->clear('SESSION');
         session_commit();
         $f3->reroute('/loggedout');
    //where loggedout is a view
            }
        );

Also i was going to use basic auth but in fact found the none basic better; you an then just use something like:
    if ($f3->get('SESSION.user_name')== NULL )

    {
     $f3->reroute('/inform/notauthorised');
     }
     //where notauthorised is a view