0
Cakephp 2.x에서 작업하고 있습니다. "logindate"라는 사용자 테이블에 필드가 있습니다. 날짜를 설정하고 있습니다. 그러나 이유를 모르겠습니다. 그것은 시스템에 처음 로그인 한 사용자에 대해 사용자 테이블에 날짜를 저장하지 않습니다. 여기에 UsersController의 코드가 있습니다. 이 저장되지 않는 이유사용자가 처음으로 시스템에 로그인 할 때 사용자 날짜를 설정합니다. Cakephp
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index');
$this->Security->requireSecure('login');// for security
$this->Auth->authenticate = array(
'Authenticate.Cookie' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'userModel' => 'User',
),
'Authenticate.MultiColumn' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'columns' => array('email', 'mobileNo'),
'userModel' => 'User',
)
);
}
public function index(){
$this->layout='logindefault';
if (!$this->Auth->login() || !$this->Auth->loggedIn()) {
$this->redirect('/users/login');
}else {
$this->redirect('/users/dashboard');
}
}
public function login() {
$this->layout='logindefault';
$this->set('title_for_layout', 'Account Login');
if ($this->Auth->login() || $this->Auth->loggedIn()) {
$this->redirect(array('controller' => 'Userinfo', 'action' => 'gettingstarted'));
//$this->redirect('/users/dashboard');
}else{
if ($this->request->is('post')) {
//here i am saving the date
$this->request->data['User']['lastLogin'] = date('y-m-d h:i:s');
$mobileNo=$this->request->data['User']['email'];
$pos = strpos($mobileNo,'@');
if($pos){
}else {
$mystr=substr($mobileNo,0,1);
if ($mystr!='+'){
$mobileNo = '+'.$mobileNo;
}
}
$this->request->data['User']['email'] = $mobileNo;
if ($this->Auth->login() || $this->Auth->loggedIn()) {
if ($this->Session->check('Auth.User')){
$this->_setCookie($this->Auth->user('idUser'));
$this->redirect(array('controller' => 'Userinfo', 'action' => 'gettingstarted'));
}
}else {
$this->Session->setFlash('Incorrect Email/Password Combination');
}
}
}
}
테스트를 위해 내가 알고 ... 해달라고 VARCHAR에 가 lastlogin의 DB에있는 데이터 유형을 변경하고이
$this->request->data['User']['lastLogin'] = "hello";
같은 값이 여전히 일을 일부러 hardcorded 사용자 ID에 대해 db로 db
: oooooooopss : p – hellosheikh