{/if}
</h3>
- {$method->getProcessor()->getStatusText($__wcf->user)}
+ {if $enabledMultifactorMethods[$method->objectTypeID]|isset}
+ {$method->getProcessor()->getStatusText($enabledMultifactorMethods[$method->objectTypeID])}
+ {/if}
</div>
<div class="accountSecurityButtons">
<?php
namespace wcf\system\user\multifactor;
-use wcf\data\user\User;
use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\ButtonFormField;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
/**
* Returns the number of remaining codes.
*/
- public function getStatusText(User $user): string {
- // TODO: Return a proper text.
- return random_int(10000, 99999)." codes remaining";
+ public function getStatusText(int $setupId): string {
+ $sql = "SELECT COUNT(*)
+ FROM wcf".WCF_N."_user_multifactor_backup
+ WHERE setupID = ?
+ AND useTime IS NULL";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$setupId]);
+
+ // TODO: Language item
+ return $statement->fetchSingleColumn()." codes remaining";
}
/**
<?php
namespace wcf\system\user\multifactor;
-use wcf\data\user\User;
use wcf\system\form\builder\IFormDocument;
/**
*/
interface IMultifactorMethod {
/**
- * Returns a human readable status text regarding the set-up status for the given user.
+ * Returns a human readable status text regarding the set-up status for the given setup.
*
* An example text could be: "5 backup codes remaining".
*/
- public function getStatusText(User $user): string;
+ public function getStatusText(int $setupId): string;
/**
* Populates the form to set-up and manage this method.
<?php
namespace wcf\system\user\multifactor;
-use wcf\data\user\User;
use wcf\system\exception\NotImplementedException;
use wcf\system\form\builder\IFormDocument;
/**
* Returns the number of devices the user set up.
*/
- public function getStatusText(User $user): string {
+ public function getStatusText(int $setupId): string {
// TODO: Return a proper text.
return random_int(10000, 99999)." devices configured";
}