<!-- /user.ban -->
<!-- user.register -->
+ <option name="force_login">
+ <categoryname>user.register</categoryname>
+ <optiontype>boolean</optiontype>
+ </option>
<option name="register_disabled">
<categoryname>user.register</categoryname>
<optiontype>boolean</optiontype>
{include file='header' __disableLoginLink=true __disableAds=true}
+{if $forceLoginRedirect}<p class="info">{lang}wcf.user.login.forceLogin{/lang}</p>{/if}
+
{if !$errorField|empty && $errorField == 'cookie'}
<p class="error">{lang}wcf.user.login.error.cookieRequired{/lang}</p>
{else}
define('SITEMAP_INDEX_TIME_FRAME', 365);
define('MODULE_TROPHY', 1);
define('ENABLE_DEVELOPER_TOOLS', 0);
+define('FORCE_LOGIN', 0);
UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($this->user, $this->username, $this->password);
}
+ if (FORCE_LOGIN) WCF::getSession()->unregister('__wsc_forceLoginRedirect');
+
// change user
WCF::getSession()->changeUser($this->user);
WCF::getTPL()->assign([
'useCookies' => $this->useCookies,
'supportsPersistentLogins' => UserAuthenticationFactory::getInstance()->getUserAuthentication()->supportsPersistentLogins(),
- 'loginController' => LinkHandler::getInstance()->getLink('Login')
+ 'loginController' => LinkHandler::getInstance()->getLink('Login'),
+ 'forceLoginRedirect' => (FORCE_LOGIN && WCF::getSession()->getVar('__wsc_forceLoginRedirect') !== null)
]);
}
<?php
namespace wcf\page;
+use wcf\form\DisclaimerForm;
+use wcf\form\EmailActivationForm;
+use wcf\form\EmailNewActivationCodeForm;
+use wcf\form\LoginForm;
+use wcf\form\LostPasswordForm;
+use wcf\form\NewPasswordForm;
+use wcf\form\RegisterActivationForm;
+use wcf\form\RegisterForm;
+use wcf\form\RegisterNewActivationCodeForm;
use wcf\system\event\EventHandler;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\menu\acp\ACPMenu;
+use wcf\system\request\LinkHandler;
use wcf\system\request\RequestHandler;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
* @inheritDoc
*/
public function show() {
+ if (FORCE_LOGIN && !RequestHandler::getInstance()->isACPRequest() && !WCF::getUser()->userID) {
+ $this->forceLogin();
+ }
+
// check if active user is logged in
if ($this->loginRequired && !WCF::getUser()->userID) {
throw new PermissionDeniedException();
}
}
}
+
+ /**
+ * Forces visitors to log-in themselves to access the site.
+ */
+ protected function forceLogin() {
+ $allowedControllers = [
+ DisclaimerForm::class,
+ EmailActivationForm::class,
+ EmailNewActivationCodeForm::class,
+ LoginForm::class,
+ LostPasswordForm::class,
+ NewPasswordForm::class,
+ RegisterActivationForm::class,
+ RegisterForm::class,
+ RegisterNewActivationCodeForm::class
+ ];
+ if (in_array(get_class($this), $allowedControllers)) {
+ // controller is allowed
+ return;
+ }
+
+ if (WCF::getActiveRequest()->isAvailableDuringOfflineMode()) {
+ // allow access to those pages that should be always available
+ return;
+ }
+
+ // force redirect to login form
+ WCF::getSession()->register('__wsc_forceLoginRedirect', true);
+ HeaderUtil::redirect(
+ LinkHandler::getInstance()->getLink('Login', [
+ 'url' => WCF::getRequestURI()
+ ])
+ );
+ exit;
+ }
}
define('URL_OMIT_INDEX_PHP', 0);
define('VISITOR_USE_TINY_BUILD', 0);
define('ENABLE_DEVELOPER_TOOLS', 0);
+define('FORCE_LOGIN', 0);
define('WCF_OPTION_INC_PHP_SUCCESS', true);
<item name="wcf.acp.option.category.module.development.notice"><![CDATA[Diese Option werden exklusiv für die Entwicklung und Fehlersuche verwendet, und sind nicht für den produktiven Einsatz geeignet.]]></item>
<item name="wcf.acp.option.enable_developer_tools"><![CDATA[Entwickler-Werkzeuge aktivieren]]></item>
<item name="wcf.acp.option.enable_developer_tools.description"><![CDATA[Aktiviert spezielle Werkzeuge die für die Plugin-Entwicklung verwendet werden. Diese Option sollte im Live-Betrieb abgeschaltet werden.]]></item>
+ <item name="wcf.acp.option.force_login"><![CDATA[Anmeldung erzwingen]]></item>
+ <item name="wcf.acp.option.force_login.description"><![CDATA[Besucher werden aufgefordert sich anzumelden, um auf die Inhalte zugreifen zu können.]]></item>
</category>
<category name="wcf.acp.customOption">
<item name="wcf.user.userAgent"><![CDATA[Browser-Kennung]]></item>
<item name="wcf.user.login"><![CDATA[Anmeldung]]></item>
<item name="wcf.user.login.error.cookieRequired"><![CDATA[Die Anmeldung erfordert den Einsatz von Cookies, bitte {if LANGUAGE_USE_INFORMAL_VARIANT}aktiviere{else}aktivieren Sie{/if} diese, um die Anmeldung durchzuführen.]]></item>
+ <item name="wcf.user.login.forceLogin"><![CDATA[Sie müssen angemeldet sein, um diese Seite aufrufen zu können.]]></item>
<item name="wcf.user.login.login"><![CDATA[Anmeldung]]></item>
<item name="wcf.user.login.register"><![CDATA[Registrierung]]></item>
<item name="wcf.user.login.register.teaser"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du hast{else}Sie haben{/if} noch kein Benutzerkonto auf unserer Seite? <a href="{link controller='Register'}{/link}">{if LANGUAGE_USE_INFORMAL_VARIANT}Registriere dich{else}Registrieren Sie sich{/if} kostenlos</a> und {if LANGUAGE_USE_INFORMAL_VARIANT}nimm{else}nehmen Sie{/if} an unserer Community teil!]]></item>
<item name="wcf.acp.option.category.module.development.notice"><![CDATA[These options are used exclusively for development and debugging, they’re not suitable for use in production environments.]]></item>
<item name="wcf.acp.option.enable_developer_tools"><![CDATA[Enable developer tools]]></item>
<item name="wcf.acp.option.enable_developer_tools.description"><![CDATA[Enables a set of specialized tools that are used for plugin development. Should always be disabled in production environments.]]></item>
+ <item name="wcf.acp.option.force_login"><![CDATA[Force login]]></item>
+ <item name="wcf.acp.option.force_login.description"><![CDATA[Visitors are required to log-in themselves to access the page.]]></item>
</category>
<category name="wcf.acp.customOption">
<item name="wcf.user.userAgent"><![CDATA[User Agent]]></item>
<item name="wcf.user.login"><![CDATA[Login]]></item>
<item name="wcf.user.login.error.cookieRequired"><![CDATA[The login requires the acceptance of cookies, please enable cookies to proceed.]]></item>
+ <item name="wcf.user.login.forceLogin"><![CDATA[You must be logged-in to access to this page.]]></item>
<item name="wcf.user.login.login"><![CDATA[Login]]></item>
<item name="wcf.user.login.register"><![CDATA[Register]]></item>
<item name="wcf.user.login.register.teaser"><![CDATA[Don’t have an account yet? <a href="{link controller='Register'}{/link}">Register yourself now</a> and be a part of our community!]]></item>