2015-06-24 27 views
0

如果用戶點擊CANCEL按鈕,當基本認證對話框出現時,如何讓FatFree重新路由到我想要的任何頁面?FatFree基本認證,取消重定向

我試着用 -

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

但這不起作用。頁被示爲具有消息:

Unauthorized 

HTTP 401 (GET /protected-url) 

回答

0
重新路由

在$ F3自舉的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