From f7a2228f263f9f24e48b63413018ca288741c0d5 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Tue, 27 Jun 2023 14:43:26 +0200 Subject: [PATCH] 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. --- src/Repository/JobRepository.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Repository/JobRepository.php b/src/Repository/JobRepository.php index da7ce1d..8f41040 100644 --- a/src/Repository/JobRepository.php +++ b/src/Repository/JobRepository.php @@ -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; }