如何在cakephp中更改用户名表和列名以进行身份验证。默认情况下,它将用户作为表名。
class AppController extends Controller {
public $components = array(
'Session','Security',
'Auth' => array(
'loginRedirect' => array('controller' => 'project', 'action' => 'index', 'Project Details'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'login')
)
);
function beforeFilter() {
$this->Auth->allow('login');
}
}
型号:
App::uses('AppModel', 'Model');
class Users extends AppModel {
var $useTable = 'manager';
}
答案 0 :(得分:0)
在AppController的beforeFilter()方法中添加以下代码
function beforeFilter(){
parent::beforeFilter();
$this->Auth->authenticate = array(
AuthComponent::ALL => array("fields" => array("username" => "your_username_column", "password" => "your_password_column") )
); }