mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-30 04:33:41 +08:00
529971c534
- Includes testing to cover flow. - Moved TOTP logic to its own controller. - Added some extra totp tests.
21 lines
412 B
PHP
21 lines
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;
|
|
}
|
|
} |