Skip to content

Commit

Permalink
Merge pull request #10 from Leuchtfeuer/YODA-353
Browse files Browse the repository at this point in the history
[TASK] Add possibility to add an anchor to the referrer url
  • Loading branch information
elbebass authored Aug 4, 2021
2 parents a40d47f + 53c86a0 commit f4ff974
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Classes/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,15 @@ protected function getAuth0(): Auth0
if ($this->auth0 instanceof Auth0) {
return $this->auth0;
}

if ($this->extensionConfiguration->isGenericCallback()) {
$callback = $this->getCallback('login');
} else {
trigger_error('Using callback settings for frontend request is deprecated as there is a dedicated callback middleware.', E_USER_DEPRECATED);
$uri = $GLOBALS['TYPO3_REQUEST']->getUri();
$referrer = sprintf('%s://%s%s', $uri->getScheme(), $uri->getHost(), $uri->getPath());
if ($this->settings['referrerAnchor']) {
$referrer .= '#' . $this->settings['referrerAnchor'];
}

$routingUtility = GeneralUtility::makeInstance(RoutingUtility::class);
$callbackSettings = $this->settings['frontend']['callback'] ?? [];
Expand All @@ -235,7 +237,11 @@ protected function getAuth0(): Auth0
protected function getCallback(string $loginType = 'login'): string
{
$uri = $GLOBALS['TYPO3_REQUEST']->getUri();

$referrer = $GLOBALS['TYPO3_REQUEST']->getQueryParams()['referrer'] ?? sprintf('%s://%s%s', $uri->getScheme(), $uri->getHost(), $uri->getPath());
if ($this->settings['referrerAnchor']) {
$referrer .= '#' . $this->settings['referrerAnchor'];
}

$tokenUtility = GeneralUtility::makeInstance(TokenUtility::class);
$tokenUtility->withPayload('application', $this->application);
Expand Down
10 changes: 10 additions & 0 deletions Configuration/FlexForms/LoginForm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@
</config>
</TCEforms>
</settings.rawAdditionalAuthorizeParameters>
<settings.referrerAnchor>
<TCEforms>
<label>LLL:EXT:auth0/Resources/Private/Language/Database.xlf:tt_content.pi_flexform.referrerAnchor</label>
<config>
<type>input</type>
<size>30</size>
<eval>trim</eval>
</config>
</TCEforms>
</settings.referrerAnchor>
</el>
</ROOT>
</sDEF>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/Database.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<trans-unit id="tt_content.pi_flexform.rawAdditionalAuthorizeParameters">
<source><![CDATA[Additional query parameters for authentication (e.g. "access_type=offline&connection=google-oauth2")]]></source>
</trans-unit>
<trans-unit id="tt_content.pi_flexform.referrerAnchor">
<source>Anchor for the referrer/callback url</source>
</trans-unit>
<trans-unit id="tt_content.pi_flexform.sheet_redirect">
<source>Redirects</source>
</trans-unit>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/de.Database.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<trans-unit id="tt_content.pi_flexform.rawAdditionalAuthorizeParameters">
<target><![CDATA[Additional query parameters for authentication (e.g. "access_type=offline&connection=google-oauth2")]]></target>
</trans-unit>
<trans-unit id="tt_content.pi_flexform.referrerAnchor">
<target>Anker für die Referrer/Callback url</target>
</trans-unit>
<trans-unit id="tt_content.pi_flexform.sheet_redirect">
<target>Weiterleitungen</target>
</trans-unit>
Expand Down

0 comments on commit f4ff974

Please sign in to comment.