Example #1
0
 /**
  * @param IOAuth2Client $client
  * @param array         $input
  *
  * @return array|bool
  * @throws OAuth2ServerException
  */
 protected function grantAccessTokenUserCredentials(IOAuth2Client $client, array $input)
 {
     if (!$this->storage instanceof IOAuth2GrantUser) {
         throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_UNSUPPORTED_GRANT_TYPE);
     }
     if (!$input["username"] || !$input["password"]) {
         throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_INVALID_REQUEST, 'Missing parameters. "username" and "password" required');
     }
     $stored = $this->storage->checkUserCredentials($client, $input["username"], $input["password"]);
     if ($stored === false) {
         throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_INVALID_GRANT, "Invalid username and password combination");
     }
     return $stored;
 }