Exemple #1
0
 /**
  * /
  * @param  [type] $user_token [description]
  * @param  [type] $type       [description]
  * @return [type]             [description]
  */
 public function validate($user_token, $type)
 {
     if (!is_string($user_token) || !is_string($type)) {
         throw new \Exception("Token and type must be strings", 07);
     }
     $token = Token::query($this->db, 'validate', $user_token, $type);
     if ($token === $user_token) {
         $sql = "UPDATE tokens SET used=NOW() \n                WHERE type=:type \n                AND token=:token";
         $this->db->run($sql, array('type' => $type, 'token' => $token));
         $sql = "SELECT id, username, email, password, activity, created \n                FROM users \n                WHERE id=:id";
         $user = $this->db->run($sql, array('id' => $record->get('user_id')));
         return $user->getFirstRecord();
     }
     return false;
 }
Exemple #2
0
 public function testValidate()
 {
     $token = '';
     $type = '';
     $result = Token::query($this->db, 'validate', $token, $type);
 }