Rename TOTP code form field to `onetimecode`
authorjoshuaruesweg <ruesweg@woltlab.com>
Sun, 11 Jul 2021 09:28:07 +0000 (11:28 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Sun, 11 Jul 2021 09:28:07 +0000 (11:28 +0200)
The name `code` for the form field is too generic and should be specified. `onetimecode` is a more fitting identifier for the input name. In addition, 1password fills the totp code automatically, if the field is named `onetimecode` (See https://1password.community/discussion/comment/604200/#Comment_604200).

wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php
wcfsetup/install/files/lib/system/user/multifactor/totp/CodeFormField.class.php

index 132322513b2b6da925dea4b2023ddfbefa13b4e5..a547508d1b1c171e58c7643373079dfcba74459a 100644 (file)
@@ -234,7 +234,7 @@ final class TotpMultifactorMethod implements IMultifactorMethod
                 Hex::encode(\random_bytes(16)),
                 $deviceName,
                 $formData['data']['secret'],
-                $formData['data']['code']['minCounter'],
+                $formData['data']['onetimecode']['minCounter'],
                 \TIME_NOW,
             ]);
 
@@ -377,10 +377,10 @@ final class TotpMultifactorMethod implements IMultifactorMethod
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute([
             \TIME_NOW,
-            $formData['data']['code']['minCounter'],
+            $formData['data']['onetimecode']['minCounter'],
             $setup->getId(),
             $formData['data']['deviceID'],
-            $formData['data']['code']['minCounter'],
+            $formData['data']['onetimecode']['minCounter'],
         ]);
 
         if ($statement->getAffectedRows() !== 1) {
index 7c07d4c308ba60243f3bddf4f5d64faf3d4362d6..7e687757756e2c148356e5f338dc620ffde6d952 100644 (file)
@@ -73,6 +73,6 @@ class CodeFormField extends TextFormField
      */
     protected static function getDefaultId(): string
     {
-        return 'code';
+        return 'onetimecode';
     }
 }