BookStack/app/Auth/Access/Mfa/BackupCodeService.php
Dan Brown 529971c534
Added backup code setup flow
- Includes testing to cover flow.
- Moved TOTP logic to its own controller.
- Added some extra totp tests.
2021-07-02 20:53:33 +01:00

21 lines
No EOL
412 B
PHP

<?php
namespace BookStack\Auth\Access\Mfa;
use Illuminate\Support\Str;
class BackupCodeService
{
/**
* Generate a new set of 16 backup codes.
*/
public function generateNewSet(): array
{
$codes = [];
for ($i = 0; $i < 16; $i++) {
$code = Str::random(5) . '-' . Str::random(5);
$codes[] = strtolower($code);
}
return $codes;
}
}