From: Tim Düsterhus Date: Tue, 26 Jan 2021 14:40:48 +0000 (+0100) Subject: Add TMultifactorRequirementEnforcer X-Git-Tag: 5.4.0_Alpha_1~353^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e09debd2af953478c795f268f7fcc8b8b458bdc4;p=GitHub%2FWoltLab%2FWCF.git Add TMultifactorRequirementEnforcer --- diff --git a/wcfsetup/install/files/lib/system/user/multifactor/TMultifactorRequirementEnforcer.class.php b/wcfsetup/install/files/lib/system/user/multifactor/TMultifactorRequirementEnforcer.class.php new file mode 100644 index 0000000000..ed128f4df8 --- /dev/null +++ b/wcfsetup/install/files/lib/system/user/multifactor/TMultifactorRequirementEnforcer.class.php @@ -0,0 +1,36 @@ + + * @package WoltLabSuite\Core\System\User\Authentication + * @since 5.4 + */ +trait TMultifactorRequirementEnforcer +{ + /** + * If the current user is in a group that requires multi-factor authentication and + * they do not have multi-factor authentication enabled, then an exception will be thrown. + * + * @throws NamedUserException If the user needs to enable multi-factor authentication. + */ + private function enforceMultifactorAuthentication(): void + { + if ( + WCF::getUser()->requiresMultifactor() + && !WCF::getUser()->multifactorActive + ) { + throw new NamedUserException(WCF::getLanguage()->getDynamicVariable( + 'wcf.user.security.requiresMultifactor' + )); + } + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 390487b4cc..9c29d1ac50 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -4975,6 +4975,7 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email} {$deviceName} wurde erfolgreich hinterlegt.]]> {$deviceName} wurde erfolgreich entfernt.]]> + die Mehrfaktor-Authentifizierung aktivieren.]]> getUserAgent()->getBrowser()}{$session->getUserAgent()->getBrowser()}{if $session->getUserAgent()->getOS()} auf {$session->getUserAgent()->getOS()}{/if}{else}Unbekanntes Gerät{/if}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 2514f274a8..e1f1a50e68 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -4972,6 +4972,7 @@ You also received a list of emergency codes to use when your second factor becom {$deviceName} has successfully been added.]]> {$deviceName} has successfully been removed.]]> + enable multi-factor authentication.]]> getUserAgent()->getBrowser()}{$session->getUserAgent()->getBrowser()}{if $session->getUserAgent()->getOS()} on {$session->getUserAgent()->getOS()}{/if}{else}Unknown Device{/if}]]>