You are here

public function ZoomApiWebhooksController::authorize in Zoom API 8

Same name and namespace in other branches
  1. 2.0.x src/Controller/ZoomApiWebhooksController.php \Drupal\zoomapi\Controller\ZoomApiWebhooksController::authorize()

Compares local webhook token to incoming.

Return value

\Drupal\Core\Access\AccessResult AccessResult allowed or forbidden.

1 string reference to 'ZoomApiWebhooksController::authorize'
zoomapi.routing.yml in ./zoomapi.routing.yml
zoomapi.routing.yml

File

src/Controller/ZoomApiWebhooksController.php, line 171

Class

ZoomApiWebhooksController
Class ZoomApiWebhooksController.

Namespace

Drupal\zoomapi\Controller

Code

public function authorize() {
  $request = $this->requestStack
    ->getCurrentRequest();

  // Token was not retreieved.
  if (!($zoomToken = $this
    ->getZoomVerificationToken($request))) {
    $this->logger
      ->debug('The Zoom API webhook post could not be verified.');
    return AccessResult::forbidden();
  }

  // Saved token matches incoming from zoom.
  if ($zoomToken === $this->webhookVerificationToken) {
    return AccessResult::allowed();
  }
  $this->logger
    ->debug('The Zoom API webhook post could not be verified.');
  return AccessResult::forbidden();
}