Cakephp 使用不同的表和列进行身份验证
如何在cakephp中更改用于身份验证的用户表名和列名。默认情况下,它以用户作为表名Cakephp 使用不同的表和列进行身份验证,cakephp,cakephp-2.0,cakephp-3.0,cakephp-2.3,cakephp-2.1,Cakephp,Cakephp 2.0,Cakephp 3.0,Cakephp 2.3,Cakephp 2.1,如何在cakephp中更改用于身份验证的用户表名和列名。默认情况下,它以用户作为表名 class AppController extends Controller { public $components = array( 'Session','Security', 'Auth' => array( 'loginRedirect' => array('controller' => 'project', 'acti
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';
}
在AppController的beforeFilter()方法中添加以下代码
function beforeFilter(){
parent::beforeFilter();
$this->Auth->authenticate = array(
AuthComponent::ALL => array("fields" => array("username" => "your_username_column", "password" => "your_password_column") )
));
}如何登录用户id和用户名$this->Auth->user('id')$此->身份验证->用户('username');