public function readParameters() {
parent::readParameters();
- if (WCF::getUser()->userID) {
- throw new PermissionDeniedException();
- }
-
if (!empty($_REQUEST['url'])) {
$this->url = StringUtil::trim($_REQUEST['url']);
}
}
+ if (WCF::getUser()->userID) {
+ // User is already logged in
+ $this->performRedirect();
+ }
+
// check authentication failures
if (ENABLE_USER_AUTHENTICATION_FAILURE) {
$failures = UserAuthenticationFailure::countIPFailures(UserUtil::getIpAddress());
WCF::getSession()->changeUser($this->user);
$this->saved();
+ $this->performRedirect();
+ }
+
+ /**
+ * Performs the redirect after successful authentication.
+ */
+ protected function performRedirect() {
if (!empty($this->url)) {
HeaderUtil::redirect($this->url);
}
// change user
WCF::getSession()->changeUser($this->user);
- // get redirect url
- $this->checkURL();
$this->saved();
// redirect to url
WCF::getTPL()->assign('__hideUserMenu', true);
- HeaderUtil::redirect($this->url);
- exit;
+
+ $this->performRedirect();
}
/**
}
/**
- * Sets the redirect url.
+ * @inheritDoc
*/
- protected function checkURL() {
- if (empty($this->url) || mb_stripos($this->url, '?Login/') !== false) {
+ protected function performRedirect() {
+ if (empty($this->url) || mb_stripos($this->url, '?login/') !== false || mb_stripos($this->url, '/login/') !== false) {
$this->url = LinkHandler::getInstance()->getLink();
}
- // drop index.php
- $this->url = preg_replace('~index\.php~', '', $this->url);
+ parent::performRedirect();
}
}