2013-12-16 33 views
-1

我在CakePHP的2.x的一个网站,我想,一个guest用户(未登录)可以看到相同的网页:
用户/登录
用户/ forgot_password
用户/ reset_password
如何允许未经身份验证的用户访问CakePHP中的内容?

我有无法访问我的页面的AuthComponent。我可以访问用户/登录,但不能忘记密码和reset_password,如果我尝试访问总是重定向到登录页面。

这是我的AppController与AuthComponent:

public $components = array(
     'Session', 
     'Auth' => array(
      'loginAction' => array('controller'=>'users','action'=>'login', 'admin'=>false), 
      'logoutRedirect' => array('controller'=>'users','action'=>'login'), 
      'loginRedirect' => array('controller'=>'projects', 'action'=>'index'), 
      'authError' => 'Questa risorsa non sembra appartenere al tuo account, oppure non hai eseguito l\'accesso', 
      'autoRedirect' => false, 
      'authorize' => array(
       'Controller', 
       'Actions' => array(
        'actionPath' => 'controllers' 
       ) 
      ), 
      'authenticate' => array(
       'Form' => array(
        'fields' => array('username' => 'email') 
       ) 
      ) 
     ) 
    ); 

在这种情况下,我无法访问forgot_password和reset_password。

但如果我把它改成这样:

public $components = array(
     'Session', 
     'Auth' => array(
      'loginAction' => null, 
      'logoutRedirect' => array('controller'=>'users','action'=>'login'), 
      'loginRedirect' => array('controller'=>'projects', 'action'=>'index'), 
      'authError' => 'Questa risorsa non sembra appartenere al tuo account, oppure non hai eseguito l\'accesso', 
      'autoRedirect' => false, 
      'authorize' => array(
       'Controller', 
       'Actions' => array(
        'actionPath' => 'controllers' 
       ) 
      ), 
      'authenticate' => array(
       'Form' => array(
        'fields' => array('username' => 'email') 
       ) 
      ) 
     ) 
    ); 

我已经在这种情况下设置nullloginAction我可以访问forgot_password和reset_password但页面是没有错误的空白,身体是空的。这些页面只是的HTML而这样的查询:

控制器动作

public function forgot_password(){ 

} 

视图

<div> 
    <p>RESTORE PASSWORD</p> 
</div> 

有人能帮助我吗?由于

回答

相关问题