gpt4 book ai didi

authentication - 在 cakePHP 中找不到授权适配器

转载 作者:行者123 更新时间:2023-12-04 06:50:11 25 4
gpt4 key购买 nike

我正在尝试将我的代码从本地移动到服务器
当我尝试登录应用程序时

enter image description here

Here is my AppController
class AppController extends Controller{
/* Determines what logged-in users access to */
var $components = array('Auth','Session');

public function isAuthorized($user){
return true;
}

public function beforeFilter(){
$userdetails = array();
$this->Auth->autoRedirect = false;
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'matches', 'action' => 'index');
$this->Auth->authorize = 'controller';
$this->Auth->authError= 'You need permissions to access this page';
$this->Auth->allow('users');
$this->set('Auth',$this->Auth);
$userdetails = $this->Auth->user();
$this->set('myUser', $userdetails['username']);
$this->set('myRole', $userdetails['user_role_id']);
$this->set('pStatus', $userdetails['password_status']);
}
}


Here is my Login Action in UsersController
public function login(){
$this->Auth->autoRedirect = false;
$id = $this->Auth->user('id');
if(empty($id)){
if($this->request->is('post')){
if($this->Auth->login()){
$this->redirect($this->Auth->redirect());
}else{
$this->Session->setFlash('Invalid Username or password');
}
}
}else{
$this->redirect(array('action'=>'index'));
}
}

谢谢您的帮助

最佳答案

您在 beforeFilter 中授权 Controller 的部分应该正确地大写:

所以:
$this->Auth->authorize = 'Controller';
代替:
$this->Auth->authorize = 'controller';
该特定语句试图找到 controllerAuthorize.php并且应该寻找 ControllerAuthorize.php .这在 Windows 上不会引起问题,但在 Unix 系统上会引起问题。

关于authentication - 在 cakePHP 中找不到授权适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10184388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com