Skip to content

Commit

Permalink
Applying the new configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntimeX committed Mar 26, 2024
1 parent 70d29ef commit f5bd2a2
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 15 deletions.
10 changes: 6 additions & 4 deletions com.woltlab.wcf/templates/accountManagement.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
</small>
{/if}
<small>{lang}wcf.user.accountManagement.password.description{/lang}</small>
<small><a href="{link controller='LostPassword'}{/link}">{lang}wcf.user.lostPassword{/lang}</a></small>
{if $__userAuthConfig->canChangePassword}
<small><a href="{link controller='LostPassword'}{/link}">{lang}wcf.user.lostPassword{/lang}</a></small>
{/if}
</dd>
</dl>

{event name='passwordFields'}
</section>
{/if}

{if $__wcf->getSession()->getPermission('user.profile.canRename')}
{if $__wcf->getSession()->getPermission('user.profile.canRename') && $__userAuthConfig->canChangeUsername}
<section class="section">
<h2 class="sectionTitle">{lang}wcf.user.changeUsername{/lang}</h2>

Expand Down Expand Up @@ -71,7 +73,7 @@
</section>
{/if}

{if !$__authProvider}
{if !$__authProvider && $__userAuthConfig->canChangePassword}
<section class="section">
<h2 class="sectionTitle">{lang}wcf.user.changePassword{/lang}</h2>

Expand Down Expand Up @@ -114,7 +116,7 @@
</section>
{/if}

{if $__wcf->getSession()->getPermission('user.profile.canChangeEmail')}
{if $__wcf->getSession()->getPermission('user.profile.canChangeEmail') && $__userAuthConfig->canChangeEmail}
<section class="section">
<h2 class="sectionTitle">{lang}wcf.user.changeEmail{/lang}</h2>

Expand Down
6 changes: 4 additions & 2 deletions com.woltlab.wcf/templates/login.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{if !REGISTER_DISABLED}
{if $__userAuthConfig->canRegister}
{capture assign='contentDescription'}{lang}wcf.user.login.noAccount{/lang}{/capture}
{/if}

Expand Down Expand Up @@ -48,7 +48,9 @@
{/if}
</small>
{/if}
<small><a href="{link controller='LostPassword'}{/link}">{lang}wcf.user.lostPassword{/lang}</a></small>
{if $__userAuthConfig->canChangePassword}
<small><a href="{link controller='LostPassword'}{/link}">{lang}wcf.user.lostPassword{/lang}</a></small>
{/if}
</dd>
</dl>

Expand Down
2 changes: 1 addition & 1 deletion com.woltlab.wcf/templates/pageHeaderUser.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
rel="nofollow"
>{lang}wcf.user.button.login{/lang}</a>
</li>
{if !REGISTER_DISABLED}
{if $__userAuthConfig->canRegister}
<li id="userRegistration">
<a
class="registrationLink"
Expand Down
4 changes: 1 addition & 3 deletions com.woltlab.wcf/templates/register.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{if !REGISTER_DISABLED}
{capture assign='contentDescription'}{lang}wcf.user.register.existingUser{/lang}{/capture}
{/if}
{capture assign='contentDescription'}{lang}wcf.user.register.existingUser{/lang}{/capture}

{include file='authFlowHeader'}

Expand Down
13 changes: 11 additions & 2 deletions wcfsetup/install/files/lib/form/AccountManagementForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
use wcf\system\menu\user\UserMenu;
use wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory;
use wcf\system\WCF;
use wcf\util\JSON;
use wcf\util\StringUtil;
Expand Down Expand Up @@ -216,7 +217,11 @@ public function validate()
}

// user name
if (WCF::getSession()->getPermission('user.profile.canRename') && $this->username != WCF::getUser()->username) {
if (
WCF::getSession()->getPermission('user.profile.canRename')
&& $this->username != WCF::getUser()->username
&& UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canChangeUsername
) {
if (\mb_strtolower($this->username) != \mb_strtolower(WCF::getUser()->username)) {
if (WCF::getUser()->lastUsernameChange + WCF::getSession()->getPermission('user.profile.renamePeriod') * 86400 > TIME_NOW) {
throw new UserInputException('username', 'alreadyRenamed');
Expand All @@ -236,7 +241,10 @@ public function validate()
}

// password
if (!WCF::getUser()->authData) {
if (
!WCF::getUser()->authData
&& UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canChangePassword
) {
if (!empty($this->newPassword)) {
if (($this->newPasswordStrengthVerdict['score'] ?? 4) < PASSWORD_MIN_SCORE) {
throw new UserInputException('newPassword', 'notSecure');
Expand All @@ -249,6 +257,7 @@ public function validate()
WCF::getSession()->getPermission('user.profile.canChangeEmail')
&& $this->email != WCF::getUser()->email
&& $this->email != WCF::getUser()->newEmail
&& UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canChangeEmail
) {
if (empty($this->email)) {
throw new UserInputException('email');
Expand Down
12 changes: 12 additions & 0 deletions wcfsetup/install/files/lib/form/LostPasswordForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use wcf\system\email\mime\MimePartFacade;
use wcf\system\email\mime\RecipientAwareTextMimePart;
use wcf\system\email\UserMailbox;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\NamedUserException;
use wcf\system\flood\FloodControl;
use wcf\system\form\builder\container\FormContainer;
Expand All @@ -17,6 +18,7 @@
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\field\validation\FormFieldValidator;
use wcf\system\request\LinkHandler;
use wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
use wcf\util\UserUtil;
Expand All @@ -36,6 +38,16 @@ final class LostPasswordForm extends AbstractFormBuilderForm

public User $user;

#[\Override]
public function checkPermissions()
{
parent::checkPermissions();

if (!UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canChangePassword) {
return new IllegalLinkException();
}
}

/**
* @inheritDoc
*/
Expand Down
3 changes: 2 additions & 1 deletion wcfsetup/install/files/lib/form/RegisterForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use wcf\system\exception\UserInputException;
use wcf\system\option\user\UserOptionHandler;
use wcf\system\request\LinkHandler;
use wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory;
use wcf\system\user\authentication\LoginRedirect;
use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
use wcf\system\user\notification\object\UserRegistrationUserNotificationObject;
Expand Down Expand Up @@ -125,7 +126,7 @@ public function readParameters()
}

// registration disabled
if (REGISTER_DISABLED) {
if (!UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canRegister) {
throw new NamedUserException(WCF::getLanguage()->get('wcf.user.register.error.disabled'));
}

Expand Down
6 changes: 5 additions & 1 deletion wcfsetup/install/files/lib/page/DisclaimerPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use wcf\page\AbstractPage;
use wcf\system\exception\NamedUserException;
use wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory;
use wcf\system\WCF;

/**
Expand All @@ -29,7 +30,10 @@ public function readParameters()
parent::readParameters();

// registration disabled
if (!WCF::getUser()->userID && REGISTER_DISABLED) {
if (
!WCF::getUser()->userID
&& !UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canRegister
) {
throw new NamedUserException(WCF::getLanguage()->get('wcf.user.register.error.disabled'));
}
}
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/files/lib/system/WCF.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ protected function assignDefaultTemplateVariables(): void
self::getTPL()->registerPrefilter(['event', 'hascontent', 'lang', 'jsphrase', 'jslang', 'csrfToken', 'icon']);
self::getTPL()->assign([
'__wcf' => $wcf,
'__userAuthConfig' => \wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory::getInstance()->getConfigration(),
]);

$isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace wcf\system\box;

use wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory;
use wcf\system\WCF;

/**
Expand All @@ -24,7 +25,10 @@ class RegisterButtonBoxController extends AbstractBoxController
*/
protected function loadContent()
{
if (!WCF::getUser()->userID && !REGISTER_DISABLED) {
if (
!WCF::getUser()->userID
&& UserAuthenticationConfigurationFactory::getInstance()->getConfigration()->canRegister
) {
$this->content = WCF::getTPL()->fetch('boxRegisterButton', 'wcf', ['box' => $this->box], true);
}
}
Expand Down

0 comments on commit f5bd2a2

Please sign in to comment.