public function quickJoin(GroupInterface $group) {

    // No group, so go home.
    if (!$group instanceof GroupInterface) {
      return new RedirectResponse(Url::fromRoute('<front>')->toString());
    }

    // It's a group, so determine the path for redirection.
    $groupRedirect = $group->toUrl()->toString();

    // Check if the settings are active.
    $active = $this->configFactory->get('social_group_quickjoin.settings')->get('social_group_quickjoin_enabled');

    // Not active, so back to group canonical.
    if (!$active) {
      // Redirect to the group.
      return new RedirectResponse($groupRedirect);
    }

    // Already a member.
    if ($group->getMember($this->currentUser())) {
      // Set a message.
      $this->messenger()->addMessage($this->t("You're already a member of this group."));
      // Redirect to the group.
      return new RedirectResponse($groupRedirect);
    }

    // Fetch the user from the accountproxy.
    $account = User::load($this->currentUser()->id());
    if ($account instanceof UserInterface) {
      // Extra exceptions based on groupmembership rules.
      if ($group->hasPermission('join group', $account) === FALSE) {
        $this->messenger()->addMessage($this->t("You don't have access to join this group."));
        return new RedirectResponse($groupRedirect);
      }

      // Add this person to the group.
      $group->addMember($account);
      // Invalidate cache of the group, so we see newest member block updated.
      $this->cache()->invalidate('group:' . $group->id());
      // Set message and redirect.
      $this->messenger()->addMessage($this->t("You've been added to this group."));
      return new RedirectResponse($groupRedirect);
    }

    // Weird behaviour if here, so just go to group home.
    return new RedirectResponse($groupRedirect);
  }