/**
  * @param string $secret
  * @return Token
  * @throws \InvalidArgumentException if the token is invalid
  */
 public function getBySecret($secret)
 {
     $token = $this->database->select(Token::class, '`secret` = ?', [$secret], 1);
     if (!$token or !$token->isValid()) {
         throw new \InvalidArgumentException('Token is not valid');
     }
     return $token;
 }
示例#2
0
 /**
  * @param string $username
  * @return User|null An user object or null if not found
  */
 public function getByUsername($username)
 {
     return $this->database->select(User::class, '`username` = ?', [$username], 1);
 }
 /**
  * @param User $user
  * @return Diagram[] All diagrams the user have saved
  */
 public function getByUser(User $user)
 {
     return $this->database->select(Diagram::class, '`userId` = ?', [$user->getId()]);
 }