Xây dựng method login (ok)
public function login($data) {
$exists = $this->find([
'conditions' => [
'email' => $data[$this->alias]['email'],
'password' => Helper::hash($data[$this->alias]['password']),
],
'first'
]);
// array (
// 'User' =>
// array (
// 'id' => '3',
// 'email' => 'lionel@gmail.com',
// 'password' => '7c4a8d09ca3762af61e59520943dc26494f8941b',
// 'fullname' => 'Lionel',
// 'address' => 'ABC',
// 'is_admin' => NULL,
// 'created' => '2020-04-03 19:24:49',
// 'modified' => '2020-04-03 19:24:49',
// ),
// )
if(!empty($exists)) {
$this->session->write(USER_INFO,$exists);
$this->session->write(LOGGED_IN,true);
return true;
}
return false;
}
Last updated