/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $adminGroup = new Groups(); $adminGroup->setGroupName('Admin Group'); $manager->persist($adminGroup); $manager->flush(); $this->addReference("admin-group", $adminGroup); }
/** * Método para cargar los datos de los grupos de los usuarios */ private function dataGroupUser(ObjectManager $manager) { $arr_context = array('SuperAdmin' => array('ROLE_ADMIN'), 'Administrador' => array('ROLE_MODERATOR'), 'Registrado' => array('ROLE_USER')); $date = new \DateTime(date('Y-m-d H:i:s')); foreach ($arr_context as $key => $value) { $context = new Groups(); $context->setName($key); $context->setRoles($value); $context->setCreatedAt($date); $context->setModifiedAt($date); $context->setCreatedBy(1); $manager->persist($context); unset($context); } $manager->flush(); }
public function getGroupKey(Groups $group) { // Get private key of current user $privKey = $this->request->getSession()->get('pkey'); // Get encrypted group key /** @var UserGroup $usergroup */ $usergroup = $this->userGroupRepository->findOneBy(['user' => $this->getUser()->getId(), 'group' => $group->getId()]); // If $usergroup is null, then current user is not a member of this group if (is_null($usergroup)) { throw new AccessDeniedHttpException("Attempt to access password user doesn't have access to"); } $encryptedGroupKey = $usergroup->getGroupKey(); // Decrypt Group key with current users private key // TODO check return if (openssl_private_decrypt($encryptedGroupKey, $groupKey, $privKey)) { $groupKey = Key::LoadFromAsciiSafeString($groupKey); return $groupKey; } else { // TODO catch this upstream? throw new \Exception("Unable to decode group key for current user"); } }