public function login($username = null, $pass = null, $remember = false) { if (!$username && !$pass && $this->exist()) { Session::put($this->_sessionName, $this->data()->id); } else { $user = $this->find($username); if ($user) { if ($this->_data->password === Hash::make($pass, $this->_data->salt)) { Session::put($this->_sessionName, $this->_data->id); if ($remember) { $hash = hash::unique(); $hashCheck = $this->_db->get('user_session', array('user_id', '=', $this->data()->id)); if (!$hashCheck->count()) { $this->_db->insert('user_session', array('user_id' => $this->_data->id, 'hash' => $hash)); } else { $hash = $hashCheck->first()->hash; } Cookies::put($this->_cookieName, $hash, config::get('remember/expiry')); } return true; } } } return false; }
public function login($email = null, $password = null, $remember = false) { if (!$email && !$password && $this->exists()) { session::put($this->_session_name, $this->_data->id); } else { $user = $this->find($email); if ($user) { if ($this->_data->password === hash::make($password, $this->_data->salt)) { session::put($this->_session_name, $this->_data->id); if ($remember) { $hash = hash::unique(); $hash_check = $this->_db->get('users_session', array('user_id', '=', $this->_data->id)); if (!$hash_check->count()) { $this->_db->insert('users_session', array('user_id' => $this->_data->id, 'hash' => $hash)); } else { $hash = $hash_check->firstResult()->hash; } cookie::put($this->_cookie_name, $hash, config::get('remember/cookie_expiry')); } return true; } } } return false; }
public function login($UserID = null, $Password = null, $remember = false) { // $user=$this->find($UserID); if (!$UserID && !$Password && $this->exists()) { session::put($this->_sessionName, $this->data()); } else { $user = $this->find($UserID); // print_r($user); // print_r($this->_data); if ($user) { if ($this->data()->Password === hash::make($Password)) { echo 'ok!'; // need to check the node_id/UserID session::put($this->_sessionName, $this->data()->node_id); if ($remember) { $hash = hash::unique(); $hashCheck = $this->_database->get('User_session', array('UserID', '=', $this->data()->node_id)); if (!$hashCheck->counts()) { $this->_database->insert('User_session', array('userID' => $this->data()->SessionID, 'Hash' => $hash)); } else { $hash = $hashCheck->first()->hash; } cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry')); } return true; } } } return false; }
public function login($username = null, $password = null, $remember = false) { if (!$username && !$password && $this->exists()) { //if no username or password sent to function and there is a user in database, used when remeber function is active session::put($this->_sessionName, $this->data()->Id); } else { $user = $this->find($username); if ($user) { if ($this->data()->Password === hash::make($password, $this->data()->Salt)) { session::put($this->_sessionName, $this->data()->Id); if ($remember) { //if remeber option selected $hash = hash::unique(); $hashCheck = $this->_db->get('User_Sessions', array('User_Id', '=', $this->data()->Id)); //check whether user session saved on db if (!$hashCheck->counts()) { $this->_db->insert('User_Sessions', array('User_Id' => $this->data()->Id, 'Hash' => $hash)); } else { $hash = $hashCheck->first()->Hash; //if already in session db use that hash (should not happen) } cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry')); //create login cookie } return true; } else { $this->_log->warning('Wrong password used for user: '******'Wrong username used: ' . $username); // Will be logged echo "Sorry, username not found. "; } } //end of not remember return false; }