diff --git a/cake3/rd_cake/src/Controller/Component/VoucherGeneratorComponent.php b/cake3/rd_cake/src/Controller/Component/VoucherGeneratorComponent.php index ec1f47b48..b7a8ea952 100644 --- a/cake3/rd_cake/src/Controller/Component/VoucherGeneratorComponent.php +++ b/cake3/rd_cake/src/Controller/Component/VoucherGeneratorComponent.php @@ -159,8 +159,8 @@ public function generateVoucher(){ } } - public function generatePassword(){ - return $this->_random_alpha_numeric(); + public function generatePassword($length = 6){ + return $this->_random_alpha_numeric($length); } public function generateUsernameForVoucher($prefix, $suffix){ diff --git a/cake3/rd_cake/src/Controller/VouchersController.php b/cake3/rd_cake/src/Controller/VouchersController.php index c520929c8..111226b5a 100644 --- a/cake3/rd_cake/src/Controller/VouchersController.php +++ b/cake3/rd_cake/src/Controller/VouchersController.php @@ -446,7 +446,9 @@ public function add(){ $s = $suffix; } $un = $this->VoucherGenerator->generateUsernameForVoucher($p,$s); - $pwd = $this->VoucherGenerator->generatePassword(); + $pwd = array_key_exists('pwd_length',$this->request->data) + ? $this->VoucherGenerator->generatePassword($this->request->data['pwd_length']) + : $this->VoucherGenerator->generatePassword(); $this->request->data['name'] = $un; $this->request->data['password'] = $pwd;