示例#1
0
 public function MatchRecord(\model\UserCredentials $credentials) : \bool
 {
     //Clean up the table by removing old passphrases
     $delete = $this->db->prepare("DELETE FROM " . self::$table . " WHERE " . self::$columnExpiration . " < NOW()");
     $delete->execute();
     $stmt = $this->db->prepare("SELECT * FROM " . self::$table . " WHERE " . self::$columnUsername . " = ? AND " . self::$columnPassphrase . " = ? AND " . self::$columnExpiration . " > ?");
     $stmt->execute(array($credentials->GetUsername(), $credentials->GetPassword(), date('Y-m-d H:i:s')));
     return $stmt->rowCount() == 1;
 }
示例#2
0
 public static function MatchRecord(\model\UserCredentials $credentials) : \bool
 {
     $file_handle = fopen(self::$logfile, "r");
     while (!feof($file_handle)) {
         $line = fgets($file_handle);
         $data = explode(self::$dataDelimiter, $line);
         if ($data[self::$username] == $credentials->GetUsername() && $data[self::$passPhrase] == $credentials->GetPassword() && $data[self::$expiration] > time()) {
             fclose($file_handle);
             return true;
         }
     }
     fclose($file_handle);
     return false;
 }
示例#3
0
 public function AuthenticateLogin(\model\UserCredentials $credentials) : \bool
 {
     foreach ($this->userDal->GetAllUsers() as $entry) {
         /* @var $entry \model\UserCredentials */
         if ($entry->GetUsername() == $credentials->GetUsername() && password_verify($credentials->GetPassword(), $entry->GetPassword())) {
             $this->LoginUser($credentials);
             return true;
         }
     }
     if ($this->persistentLoginDAL->MatchRecord($credentials)) {
         $this->LoginUser($credentials);
         return true;
     }
     return false;
 }
示例#4
0
 public function AuthenticateLogin(\model\UserCredentials $credentials) : \bool
 {
     return $credentials->GetUsername() === self::$username && $credentials->GetPassword() === self::$password || dal\PersistentLoginDAL::MatchRecord($credentials);
 }