529971c534
- Includes testing to cover flow. - Moved TOTP logic to its own controller. - Added some extra totp tests.
21 lines
No EOL
412 B
PHP
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;
|
|
}
|
|
} |