Merge pull request #7649 from kinglozzer/logout-backurl

FIX: Restore BackURL preservation on log out (closes #7636)
This commit is contained in:
Damian Mooyman 2017-11-29 11:31:57 +13:00 committed by GitHub
commit c23d1f3f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
namespace SilverStripe\Security\MemberAuthenticator; namespace SilverStripe\Security\MemberAuthenticator;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPResponse; use SilverStripe\Control\HTTPResponse;
use SilverStripe\Control\RequestHandler; use SilverStripe\Control\RequestHandler;
@ -109,6 +110,14 @@ class LogoutHandler extends RequestHandler
return $this->redirect($backURL); return $this->redirect($backURL);
} }
return $this->redirect(Security::config()->get('login_url')); $link = Security::config()->get('login_url');
$referer = $this->getReturnReferer();
if ($referer) {
$link = Controller::join_links($link, '?' . http_build_query([
'BackURL' => Director::makeRelative($referer)
]));
}
return $this->redirect($link);
} }
} }