FatFree基本身份验证,取消时重新路由

时间:2015-06-24 12:03:25

标签: basic-authentication fat-free-framework

如果用户点击CANCEL按钮,当基本身份验证对话框出现时,如何将FatFree重新路由到我想要的任何页面?

我试过 -

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

但这不起作用。页面显示消息:

Unauthorized

HTTP 401 (GET /protected-url)

1 个答案:

答案 0 :(得分:0)

在$ f3 bootstrap中重新路由index.php可以像这样使用:

  //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