Exemple #1
0
 public function login($username = null, $password = null, $remember = false)
 {
     if (!$username && !$password && $this->exists()) {
         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) {
                     $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;
                     }
                     cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }