]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/Access/Mfa/BackupCodeService.php
Added test for logical-theme-system command registration
[bookstack] / app / Auth / Access / Mfa / BackupCodeService.php
index 6fbbf64b5d8b50cab078d688f03d7f4485b26c9c..d58d28ae12f4a115c7cf9d6a5bd92e50dcce66af 100644 (file)
@@ -29,25 +29,21 @@ class BackupCodeService
     {
         $cleanCode = $this->cleanInputCode($code);
         $codes = json_decode($codeSet);
+
         return in_array($cleanCode, $codes);
     }
 
     /**
      * Remove the given input code from the given available options.
-     * Will return null if no codes remain otherwise will be a JSON string to contain
-     * the codes.
+     * Will return a JSON string containing the codes.
      */
-    public function removeInputCodeFromSet(string $code, string $codeSet): ?string
+    public function removeInputCodeFromSet(string $code, string $codeSet): string
     {
         $cleanCode = $this->cleanInputCode($code);
         $codes = json_decode($codeSet);
         $pos = array_search($cleanCode, $codes, true);
         array_splice($codes, $pos, 1);
 
-        if (count($codes) === 0) {
-            return null;
-        }
-
         return json_encode($codes);
     }
 
@@ -63,4 +59,4 @@ class BackupCodeService
     {
         return strtolower(str_replace(' ', '-', trim($code)));
     }
-}
\ No newline at end of file
+}