You are here

public function AuthenticationController::viewProfile in Janrain Registration 8

View profile page.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The incoming HTTP request.

1 string reference to 'AuthenticationController::viewProfile'
janrain_capture.routing.yml in ./janrain_capture.routing.yml
janrain_capture.routing.yml

File

src/Controller/AuthenticationController.php, line 89

Class

AuthenticationController
Authentication controller.

Namespace

Drupal\janrain_capture\Controller

Code

public function viewProfile(Request $request) {
  if (!$request->query
    ->get('uuid')) {
    $user = User::load(\Drupal::currentUser()
      ->id());
    $uuid = $user
      ->uuid();
    return new RedirectResponse(Url::fromRoute('janrain_capture.view_profile', [
      'uuid' => $uuid,
    ])
      ->toString(), RedirectResponse::HTTP_MOVED_PERMANENTLY);
  }

  // Get current user's UUID and compare it against UUID from the parameter.
  $current_janrain_uuid = $this->captureApi
    ->getUserProfile()
    ->getUuid();
  if ($current_janrain_uuid == $_GET['uuid']) {
    return $this->markupBuilder
      ->getScreenRenderArray('public-profile');
  }
  else {
    throw new \InvalidArgumentException('An invalid uuid is given.');
  }
}