我正在使用cakephp Auth登录它不能在线工作,但在localhost上工作正常。
class AppController extends Controller {
public $components=array(
'Auth'=>array(
'authenticate'=>array(
'Form'=>array(
'userModel'=>'User',
'fields'=>array(
'username'=>'uid',
'password'=>'password',
),
)
),
'loginAction' => array('controller' => 'users', 'action' => 'login'),
'loginRedirect' => array('controller' => 'users', 'action' => 'dashboard'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
'authError' => 'You don\'t have access here.',
),
'Session'
);
在UsersController中这个login()方法在localhost上工作正常我们在cakephp上传服务器上的任何文件时应该做什么改动
public function login(){
$this->layout='login';
if($this->request->is('Post'))
{
if($this->Auth->login())
{
$user=$this->Auth->user();
if($user['status']!=0 || $user['role']=='1')
{
if($user['role'])
{
$role="Admin";
$this->Session->write('admin',$user['uid']);
}
else
{
$role="User";
$this->Session->write('user',$user['uid']);
}
$this->Session->write('rolename',$role);
$this->Session->write('uid',$user['uid']);
$log['Log']['loginType']=$this->request->data['User']['loginType'];
$log['Log']['userId']=$user['id'];
$log['Log']['latitude']='0';//$data['User']['latitude'];
$log['Log']['longitude']='0';//$data['User']['longitude'];
$this->Log->save($log);
$this->Flash->set(_('Sucessfully login'));
$this->redirect(array('controller'=>'users','action'=>'dashboard'));
}
else
{
$this->Flash->set('You have no access to login...');
}
}
else
$this->Flash->set('Invalid Credentials');
}
}