Add multifactor language items
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 Nov 2020 13:35:49 +0000 (14:35 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 16 Nov 2020 16:26:05 +0000 (17:26 +0100)
com.woltlab.wcf/templates/accountSecurity.tpl
wcfsetup/install/files/lib/page/AccountSecurityPage.class.php
wcfsetup/install/files/lib/system/user/multifactor/BackupMultifactorMethod.class.php
wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 68eee0901e781e592b9314469eff4150383b3042..810b2556ae5a6300f146bca0ece1e16b85decef9 100644 (file)
@@ -25,7 +25,7 @@
                                                </h3>
                                                
                                                {if $enabledMultifactorMethods[$method->objectTypeID]|isset}
-                                                       {$method->getProcessor()->getStatusText($enabledMultifactorMethods[$method->objectTypeID])}
+                                                       {@$method->getProcessor()->getStatusText($enabledMultifactorMethods[$method->objectTypeID])}
                                                {/if}
                                        </div>
                                        
index e1b3296c4f376f91ba2a663b74d62e7cfa533f37..95f6b05565517d0995e10da41a1145cc69c51194 100644 (file)
@@ -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()));
index 316d12d85262956b11502e813fcc553fe0b1a0a3..5a253470970dbeef7909f35a46af8946da578063 100644 (file)
@@ -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()
+               );
+
        }
        
        /**
index 50aa6be021e2a2c59de8a65430322fcf17c4da15..a9816368385e54cb9303fe82832dc52bd1a390fa 100644 (file)
@@ -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()
+               );
        }
        
        /**
index 97ceff7f38f540112fb023ee237484d533e5bc8f..433815cee890488ce55fcd4a9711b7b6ea08186d 100644 (file)
@@ -4831,6 +4831,30 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email}
                <item name="wcf.user.security.sessionName"><![CDATA[{if $session->getUserAgent()->getBrowser()}{$session->getUserAgent()->getBrowser()}{if $session->getUserAgent()->getOS()} auf {$session->getUserAgent()->getOS()}{/if}{else}Unbekanntes Gerät{/if}]]></item>
                <item name="wcf.user.security.ipAddress"><![CDATA[IP-Adresse]]></item>
                <item name="wcf.user.security.lastActivity"><![CDATA[Sitzung zuletzt aktiv]]></item>
+               <item name="wcf.user.security.multifactor"><![CDATA[Mehrfaktor-Authentifizierung]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.totp"><![CDATA[Smartphone-App]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.backup"><![CDATA[Notfall-Codes]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.backup.manage"><![CDATA[Notfallcodes verwalten]]></item>
+               <item name="wcf.user.security.multifactor.backup.regenerateCodes"><![CDATA[Neue Codes generieren]]></item>
+               <item name="wcf.user.security.multifactor.backup.existingCodes"><![CDATA[Aktive Codes]]></item>
+               <item name="wcf.user.security.multifactor.backup.success"><![CDATA[Es wurden erfolgreich neue Codes generiert. Bestehende Codes sind nicht mehr gültig. Bitte {if LANGUAGE_USE_INFORMAL_VARIANT}schreibe dir{else}schreiben Sie sich{/if} die Codes gut auf!]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.totp.manage"><![CDATA[Smartphone-App verwalten]]></item>
+               <item name="wcf.user.security.multifactor.totp.newDevice"><![CDATA[Smartphone hinzufügen]]></item>
+               <item name="wcf.user.security.multifactor.totp.deviceName"><![CDATA[Name des Geräts]]></item>
+               <item name="wcf.user.security.multifactor.totp.deviceName.placeholder"><![CDATA[Smartphone von {$__wcf->user->username}]]></item>
+               <item name="wcf.user.security.multifactor.totp.code"><![CDATA[Einmalcode]]></item>
+               <item name="wcf.user.security.multifactor.totp.status"><![CDATA[<ul class="inlineList small commaSeparated">
+<li>{plural value=$count 0="Nicht eingerichtet" 1="Ein Gerät eingerichtet" other="# Geräte eingerichtet"}</li>
+{if $lastUsed}<li>Am {@$lastUsed|plainTime} zuletzt verwendet</li>{/if}
+</ul>]]></item>
+               <item name="wcf.user.security.multifactor.backup.status"><![CDATA[<ul class="inlineList small commaSeparated">
+<li>{plural value=$count 0="Keine Codes verbleibend" 1="Ein Code verbleibend" other="# Codes verbleibend"}</li>
+{if $lastUsed}<li>Am {@$lastUsed|plainTime} zuletzt verwendet</li>{/if}
+</ul>]]></item>
+               <item name="wcf.user.security.multifactor.manage"><![CDATA[Verwalten]]></item>
+               <item name="wcf.user.security.multifactor.setup"><![CDATA[Einrichten]]></item>
+               <item name="wcf.user.security.multifactor.active"><![CDATA[Aktiv]]></item>
+               <item name="wcf.user.security.multifactor.backup.generateCodes"><![CDATA[Codes generieren]]></item>
        </category>
        <category name="wcf.user.trophy">
                <item name="wcf.user.trophy.trophyPoints"><![CDATA[Trophäen]]></item>
index de6610797701a41894923f86dc7cf8468166c44b..8cd607cfc4872d5905c4d2a3eb5401455f90e582 100644 (file)
@@ -4828,6 +4828,30 @@ Open the link below to access the user profile:
                <item name="wcf.user.security.sessionName"><![CDATA[{if $session->getUserAgent()->getBrowser()}{$session->getUserAgent()->getBrowser()}{if $session->getUserAgent()->getOS()} on {$session->getUserAgent()->getOS()}{/if}{else}Unknown Device{/if}]]></item>
                <item name="wcf.user.security.ipAddress"><![CDATA[IP Address]]></item>
                <item name="wcf.user.security.lastActivity"><![CDATA[Last active]]></item>
+               <item name="wcf.user.security.multifactor"><![CDATA[Multifactor Authentication]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.totp"><![CDATA[Smartphone App]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.backup"><![CDATA[Emergency Codes]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.backup.manage"><![CDATA[Manage Emergency Codes]]></item>
+               <item name="wcf.user.security.multifactor.backup.regenerateCodes"><![CDATA[Generate New Codes]]></item>
+               <item name="wcf.user.security.multifactor.backup.existingCodes"><![CDATA[Active Codes]]></item>
+               <item name="wcf.user.security.multifactor.backup.success"><![CDATA[New Codes were generated successfully. Any existing codes are no longer valid. Please carefully note down the codes.]]></item>
+               <item name="wcf.user.security.multifactor.com.woltlab.wcf.multifactor.totp.manage"><![CDATA[Manage Smartphone App]]></item>
+               <item name="wcf.user.security.multifactor.totp.newDevice"><![CDATA[Add Smartphone]]></item>
+               <item name="wcf.user.security.multifactor.totp.deviceName"><![CDATA[Device Name]]></item>
+               <item name="wcf.user.security.multifactor.totp.deviceName.placeholder"><![CDATA[{$__wcf->user->username}’s Smartphone]]></item>
+               <item name="wcf.user.security.multifactor.totp.code"><![CDATA[One Time Code]]></item>
+               <item name="wcf.user.security.multifactor.totp.status"><![CDATA[<ul class="inlineList small commaSeparated">
+<li>{plural value=$count 0="Not set up" 1="One device set up" other="# devices set up"}</li>
+{if $lastUsed}<li>Last used on {@$lastUsed|plainTime}</li>{/if}
+</ul>]]></item>
+               <item name="wcf.user.security.multifactor.backup.status"><![CDATA[<ul class="inlineList small commaSeparated">
+<li>{plural value=$count 0="No codes remaining" 1="One code remaining" other="# codes remaining"}</li>
+{if $lastUsed}<li>Last used on {@$lastUsed|plainTime}</li>{/if}
+</ul>]]></item>
+               <item name="wcf.user.security.multifactor.manage"><![CDATA[Manage]]></item>
+               <item name="wcf.user.security.multifactor.setup"><![CDATA[Set Up]]></item>
+               <item name="wcf.user.security.multifactor.active"><![CDATA[Active]]></item>
+               <item name="wcf.user.security.multifactor.backup.generateCodes"><![CDATA[Generate Codes]]></item>
        </category>
        <category name="wcf.user.trophy">
                <item name="wcf.user.trophy.trophyPoints"><![CDATA[Trophies]]></item>