|
|
@@ -0,0 +1,49 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace Opentalent\OtCore\Middleware\Frontend;
|
|
|
+
|
|
|
+
|
|
|
+use Psr\Http\Message\ResponseInterface;
|
|
|
+use Psr\Http\Message\ServerRequestInterface;
|
|
|
+use Psr\Http\Server\MiddlewareInterface;
|
|
|
+use Psr\Http\Server\RequestHandlerInterface;
|
|
|
+use TYPO3\CMS\Core\Http\Stream;
|
|
|
+use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
|
|
|
+use TYPO3\CMS\Core\Page\PageRenderer;
|
|
|
+use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
+
|
|
|
+/**
|
|
|
+ * /!\ 2021-06 - This is a special and TEMPORARY patch for https://assistance.opentalent.fr/browse/V8-2247
|
|
|
+ *
|
|
|
+ * Because FE authentication doesn't work on domain that are not in *.opentalent.fr, i.e. organizations that
|
|
|
+ * have a custom domain set, both domains have to be kept available: the custom one and the <sub>.opentalent.fr one.
|
|
|
+ *
|
|
|
+ * But, we don't want the second one to be indexed by search engines.
|
|
|
+ *
|
|
|
+ * This middleware set the 'robots' meta tag to noindex mode if the domain matches this special case.
|
|
|
+ *
|
|
|
+ * Because Typoscript is processed after this, the page.meta.robots line had to be commented.
|
|
|
+ * The default meta tag has been moved here.
|
|
|
+ *
|
|
|
+ * !! When this middleware will be useless, **remind to re-enable the typoscript directive!**
|
|
|
+ *
|
|
|
+ * @package Opentalent\OtCore\Middleware\Frontend
|
|
|
+ */
|
|
|
+class OtMetaNoIndexAdder implements MiddlewareInterface
|
|
|
+{
|
|
|
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
|
|
+ {
|
|
|
+ $metaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('robots');
|
|
|
+ if (
|
|
|
+ $GLOBALS['TYPO3_REQUEST']->getAttribute('ot_website')['custom_domain'] &&
|
|
|
+ preg_match("/[\w\-]+\.opentalent\.fr(:\d+)?/", $_SERVER['HTTP_HOST'])
|
|
|
+ ) {
|
|
|
+ $metaTagManager->addProperty('robots', 'noindex,nofollow');
|
|
|
+ } else {
|
|
|
+ $metaTagManager->addProperty('robots', 'index,follow,archive');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $handler->handle($request);
|
|
|
+ }
|
|
|
+}
|