Fix backup codes not deleting

This commit is contained in:
Jack Anderson 2025-01-17 10:31:21 +00:00 committed by j.anderson
parent c7eb2027ed
commit 90bff782b5

View file

@ -1320,12 +1320,13 @@ class User implements UserInterface, EquatableInterface, PasswordAuthenticatedUs
*/
public function invalidateBackupCode(string $code): void
{
$key = array_search($code, $this->getBackupCodes(), true);
$backupCodes = $this->getBackupCodes();
$key = array_search($code, $backupCodes, true);
if ($key !== false){
unset($this->getBackupCodes()[$key]);
unset($backupCodes[$key]);
}
$this->backupCodes = array_values($this->backupCodes);
$this->setBackupCodes(array_values($backupCodes));
}
}