feature/MAPG-235-basic-challenge-mode #48
@ -112,11 +112,10 @@ class GameController implements ISecured
|
|||||||
public function createNewChallenge(): IContent
|
public function createNewChallenge(): IContent
|
||||||
{
|
{
|
||||||
// create Challenge
|
// create Challenge
|
||||||
$challengeToken = rand();
|
do {
|
||||||
while ($this->challengeRepository->getByToken($challengeToken)) {
|
// initiliaze or if a challenge with the same token already exists
|
||||||
// if a challenge with the same token already exists
|
$challengeToken = mt_rand();
|
||||||
$challengeToken = rand();
|
} while ($this->challengeRepository->getByToken($challengeToken));
|
||||||
}
|
|
||||||
|
|
||||||
$challenge = new Challenge();
|
$challenge = new Challenge();
|
||||||
$challenge->setToken($challengeToken);
|
$challenge->setToken($challengeToken);
|
||||||
|
@ -57,11 +57,9 @@ class UserInChallengeRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate token string
|
// validate token string
|
||||||
foreach (str_split($token_str) as $char) {
|
if (!ctype_xdigit($token_str)) {
|
||||||
if (!(('0' <= $char && $char <= '9') || ('a' <= $char && $char <= 'f'))) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// convert token to int
|
// convert token to int
|
||||||
$token = hexdec($token_str);
|
$token = hexdec($token_str);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user