You are here

public function MultipleRegistrationController::authenticatedUserRedirect in Multiple Registration 8.2

Same name and namespace in other branches
  1. 3.x src/Controller/MultipleRegistrationController.php \Drupal\multiple_registration\Controller\MultipleRegistrationController::authenticatedUserRedirect()

Redirects the current user to its profile page if user has logged in.

Parameters

\Drupal\Core\Session\AccountInterface $account: Current user account object.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse|null Returns RedirectResponse object or NULL.

File

src/Controller/MultipleRegistrationController.php, line 154

Class

MultipleRegistrationController
Class MultipleRegistrationController.

Namespace

Drupal\multiple_registration\Controller

Code

public function authenticatedUserRedirect(AccountInterface $account) {
  $is_redirect_enabled = FALSE;
  $config = $this
    ->config('multiple_registration.common_settings_page_form_config');
  if ($config !== NULL && $config !== $config
    ->isNew()) {
    $is_redirect_enabled = $config
      ->get('enable_redirect_to_user_profile_when_user_logged_in');
  }
  if ($account
    ->isAuthenticated() && $is_redirect_enabled) {
    return $this
      ->redirect('user.page', [
      'user' => $account
        ->id(),
    ])
      ->send();
  }
  return NULL;
}