Alternate method for generating codes.
This commit is contained in:
parent
a9e40361c2
commit
cf87a2d592
1 changed files with 4 additions and 2 deletions
|
@ -3,12 +3,14 @@ namespace Mince;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Index\Base32;
|
use Index\XString;
|
||||||
use Index\Data\{DbStatementCache,IDbConnection};
|
use Index\Data\{DbStatementCache,IDbConnection};
|
||||||
use Index\Net\IPAddress;
|
use Index\Net\IPAddress;
|
||||||
use Ramsey\Uuid\UuidInterface;
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
|
||||||
class Verifications {
|
class Verifications {
|
||||||
|
private const CODE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||||
|
|
||||||
private IDbConnection $dbConn;
|
private IDbConnection $dbConn;
|
||||||
private DbStatementCache $cache;
|
private DbStatementCache $cache;
|
||||||
|
|
||||||
|
@ -18,7 +20,7 @@ class Verifications {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateCode(): string {
|
public static function generateCode(): string {
|
||||||
return Base32::encode(random_bytes(6));
|
return XString::random(10, self::CODE_CHARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prune(): void {
|
public function prune(): void {
|
||||||
|
|
Loading…
Reference in a new issue