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:
parent
2b1a7939e3
commit
f7a2228f26
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue