From: Tim Düsterhus Date: Fri, 6 Nov 2020 13:35:49 +0000 (+0100) Subject: Add multifactor language items X-Git-Tag: 5.4.0_Alpha_1~555^2~53^2~20 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6128e9fff91feb6d5dda2e7a0cab0f074802eb24;p=GitHub%2FWoltLab%2FWCF.git Add multifactor language items --- diff --git a/com.woltlab.wcf/templates/accountSecurity.tpl b/com.woltlab.wcf/templates/accountSecurity.tpl index 68eee0901e..810b2556ae 100644 --- a/com.woltlab.wcf/templates/accountSecurity.tpl +++ b/com.woltlab.wcf/templates/accountSecurity.tpl @@ -25,7 +25,7 @@ {if $enabledMultifactorMethods[$method->objectTypeID]|isset} - {$method->getProcessor()->getStatusText($enabledMultifactorMethods[$method->objectTypeID])} + {@$method->getProcessor()->getStatusText($enabledMultifactorMethods[$method->objectTypeID])} {/if} diff --git a/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php b/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php index e1b3296c4f..95f6b05565 100644 --- a/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php +++ b/wcfsetup/install/files/lib/page/AccountSecurityPage.class.php @@ -50,6 +50,11 @@ class AccountSecurityPage extends AbstractPage { }); $this->multifactorMethods = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.multifactor'); + + usort($this->multifactorMethods, function (ObjectType $a, ObjectType $b) { + return $b->priority <=> $a->priority; + }); + $this->enabledMultifactorMethods = array_flip(array_map(function (ObjectType $o) { return $o->objectTypeID; }, WCF::getUser()->getEnabledMultifactorMethods())); diff --git a/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php index 316d12d852..5a25347097 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php @@ -38,15 +38,17 @@ class BackupMultifactorMethod implements IMultifactorMethod { * Returns the number of remaining codes. */ public function getStatusText(int $setupId): string { - $sql = "SELECT COUNT(*) + $sql = "SELECT COUNT(*) - COUNT(useTime) AS count, MAX(useTime) AS lastUsed FROM wcf".WCF_N."_user_multifactor_backup - WHERE setupID = ? - AND useTime IS NULL"; + WHERE setupID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$setupId]); - // TODO: Language item - return $statement->fetchSingleColumn()." codes remaining"; + return WCF::getLanguage()->getDynamicVariable( + 'wcf.user.security.multifactor.backup.status', + $statement->fetchArray() + ); + } /** diff --git a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php index 50aa6be021..a981636838 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php @@ -28,14 +28,16 @@ class TotpMultifactorMethod implements IMultifactorMethod { * Returns the number of devices the user set up. */ public function getStatusText(int $setupId): string { - $sql = "SELECT COUNT(*) + $sql = "SELECT COUNT(*) AS count, MAX(useTime) AS lastUsed FROM wcf".WCF_N."_user_multifactor_totp WHERE setupID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$setupId]); - // TODO: Language item - return $statement->fetchSingleColumn()." devices configured"; + return WCF::getLanguage()->getDynamicVariable( + 'wcf.user.security.multifactor.totp.status', + $statement->fetchArray() + ); } /** diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 97ceff7f38..433815cee8 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -4831,6 +4831,30 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email} getUserAgent()->getBrowser()}{$session->getUserAgent()->getBrowser()}{if $session->getUserAgent()->getOS()} auf {$session->getUserAgent()->getOS()}{/if}{else}Unbekanntes Gerät{/if}]]> + + + + + + + + + + + user->username}]]> + + +
  • {plural value=$count 0="Nicht eingerichtet" 1="Ein Gerät eingerichtet" other="# Geräte eingerichtet"}
  • +{if $lastUsed}
  • Am {@$lastUsed|plainTime} zuletzt verwendet
  • {/if} +]]>
    + +
  • {plural value=$count 0="Keine Codes verbleibend" 1="Ein Code verbleibend" other="# Codes verbleibend"}
  • +{if $lastUsed}
  • Am {@$lastUsed|plainTime} zuletzt verwendet
  • {/if} +]]>
    + + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index de66107977..8cd607cfc4 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -4828,6 +4828,30 @@ Open the link below to access the user profile: getUserAgent()->getBrowser()}{$session->getUserAgent()->getBrowser()}{if $session->getUserAgent()->getOS()} on {$session->getUserAgent()->getOS()}{/if}{else}Unknown Device{/if}]]> + + + + + + + + + + + user->username}’s Smartphone]]> + + +
  • {plural value=$count 0="Not set up" 1="One device set up" other="# devices set up"}
  • +{if $lastUsed}
  • Last used on {@$lastUsed|plainTime}
  • {/if} +]]>
    + +
  • {plural value=$count 0="No codes remaining" 1="One code remaining" other="# codes remaining"}
  • +{if $lastUsed}
  • Last used on {@$lastUsed|plainTime}
  • {/if} +]]>
    + + + +