Refactor JobRepository's addToken method for generating hook tokens

This commit refactors the addToken method in JobRepository to generate a random string of 32 characters using alphanumeric characters. The new implementation replaces the previous code that generated the token.
This commit is contained in:
Jeroen De Meerleer 2023-06-27 14:43:26 +02:00
parent 2b1a7939e3
commit f7a2228f26
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
1 changed files with 1 additions and 10 deletions

View File

@ -741,16 +741,7 @@ class JobRepository extends EntityRepository
}
}
if(empty($job->getData('hooktoken'))) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
$length = 32;
for ($i = 0; $i < $length; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
$job->setData('hooktoken', $randomString);
$job->addToken();
}
return $job;
}