Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add L parameter to login_redirect_url #117

Open
stat1x opened this issue Mar 13, 2019 · 7 comments
Open

Add L parameter to login_redirect_url #117

stat1x opened this issue Mar 13, 2019 · 7 comments

Comments

@stat1x
Copy link

stat1x commented Mar 13, 2019

The L parameter is missing in the login_redirect_url so if I am on a page with L parameter set to 1 (my-site.com/index.php?id=111&L=1) and I don't have access to a file I need to download I am redirected to the login page but without the L parameter.

@frans-beech-it
Copy link
Contributor

Hi,

As workarround you could adjust the login_redirect_url config in you LocalConfiguration.php based on the _GET['L'] param.

But PR's are welcome :)

@stat1x
Copy link
Author

stat1x commented Mar 14, 2019

I'm gonna try to manage this PR. But I think there are several things to take into account.

  1. The language parameter should be somehow added to the protected file URLs.
  2. Modify the redirectToUrl method to add the L parameter to the $redirect_uri with GeneralUtility::_GET('L').

Do you think it is the right way to do it?

@frans-beech-it
Copy link
Contributor

Yes that looks like whats needed:

  1. Use the ResourceStorage::preGeneratePublicUrl signal to add the 'L' param to the url (but this should be added to the url by the core itself)
  2. Change FileDumpHook::redirectToUrl() to add the extra replacement to the url
  3. Update the documentation ;)

@stat1x
Copy link
Author

stat1x commented Mar 19, 2019

(but this should be added to the url by the core itself)

You mean it's a missing feature from the core? Should I add a ticket on forge to get ride of it?

@fsaris
Copy link
Contributor

fsaris commented Mar 19, 2019

Yes please

@stat1x
Copy link
Author

stat1x commented Mar 19, 2019

Here is the link to the issue : https://forge.typo3.org/issues/87955

@eckonator
Copy link

Here is my (dirty?) solution for this problem. I'm running TYPO3 9.5.
I added this code into my AdditionalConfiguration.php and it's working for me:

//var_dump($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['fal_securedownload']["login_redirect_url"]);
//echo "<br />";
$referrer = $_SERVER['HTTP_REFERER'];
if($referrer) {
    $parsedUrl = parse_url($referrer);
    $referrerRequestUri = $parsedUrl['path'];
    if($referrerRequestUri) {
        if(substr( $referrerRequestUri, 0, 4 ) === "/en/" || $referrerRequestUri === "/en") {
            $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['fal_securedownload']["login_redirect_url"] = "/en/download-denied/";
        } else if(substr( $referrerRequestUri, 0, 4 ) === "/fr/" || $referrerRequestUri === "/fr") {
            $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['fal_securedownload']["login_redirect_url"] = "/fr/telechargement-refuse/";
        } else {
            $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['fal_securedownload']["login_redirect_url"] = "/de/download-verweigert/";
        }
    //  var_dump($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['fal_securedownload']["login_redirect_url"]);
    //  die();
    }
}

Maybe it helps someone else :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants