mirror of https://github.com/sualko/cloud_bbb
fix: use injection for random generator
parent
27aa28da81
commit
b7ad4367e2
|
@ -13,6 +13,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class RoomService {
|
class RoomService {
|
||||||
|
|
||||||
|
@ -25,13 +26,18 @@ class RoomService {
|
||||||
/** @var IEventDispatcher */
|
/** @var IEventDispatcher */
|
||||||
private $eventDispatcher;
|
private $eventDispatcher;
|
||||||
|
|
||||||
|
/** @var ISecureRandom */
|
||||||
|
private $random;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
RoomMapper $mapper,
|
RoomMapper $mapper,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IEventDispatcher $eventDispatcher) {
|
IEventDispatcher $eventDispatcher,
|
||||||
|
ISecureRandom $random) {
|
||||||
$this->mapper = $mapper;
|
$this->mapper = $mapper;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
$this->random = $random;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
||||||
|
@ -84,12 +90,12 @@ class RoomService {
|
||||||
|
|
||||||
$mediaCheck = $this->config->getAppValue('bbb', 'join.mediaCheck', 'true') === 'true';
|
$mediaCheck = $this->config->getAppValue('bbb', 'join.mediaCheck', 'true') === 'true';
|
||||||
|
|
||||||
$room->setUid(\OC::$server->getSecureRandom()->generate(16, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE));
|
$room->setUid($this->humanReadableRandom(16));
|
||||||
$room->setName($name);
|
$room->setName($name);
|
||||||
$room->setWelcome($welcome);
|
$room->setWelcome($welcome);
|
||||||
$room->setMaxParticipants(\max($maxParticipants, 0));
|
$room->setMaxParticipants(\max($maxParticipants, 0));
|
||||||
$room->setAttendeePassword(\OC::$server->getSecureRandom()->generate(32, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE));
|
$room->setAttendeePassword($this->humanReadableRandom(32));
|
||||||
$room->setModeratorPassword(\OC::$server->getSecureRandom()->generate(32, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE));
|
$room->setModeratorPassword($this->humanReadableRandom(32));
|
||||||
$room->setRecord($record);
|
$room->setRecord($record);
|
||||||
$room->setAccess($access);
|
$room->setAccess($access);
|
||||||
$room->setUserId($userId);
|
$room->setUserId($userId);
|
||||||
|
@ -178,6 +184,6 @@ class RoomService {
|
||||||
* @param int $length
|
* @param int $length
|
||||||
*/
|
*/
|
||||||
private function humanReadableRandom(int $length) {
|
private function humanReadableRandom(int $length) {
|
||||||
return \OC::$server->getSecureRandom()->generate($length, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE);
|
return $this->random->generate($length, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue