MAPG-235 challenge token related error handling
This commit is contained in:
1 parent
3b98570f6d
commit
bbb66ca979
3 files changed
+18
No files matched your search
@@ -31,6 +31,13 @@ class ChallengeRepository
|
||||
|
||||
public function getByTokenStr(string $token_str): ?Challenge
|
||||
{
|
||||
// validate token string
|
||||
foreach (str_split($token_str) as $char) {
|
||||
if (!(('0' <= $char && $char <= '9') || ('a' <= $char && $char <= 'f'))) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// convert token to int
|
||||
$token = hexdec($token_str);
|
||||
|
||||
return $this->getByToken($token);
|
||||
|
||||
Reference in new issue
Block a user