Skip to content

Commit

Permalink
Merge pull request #99 from H2-invent/feature/changecollumname
Browse files Browse the repository at this point in the history
Feature/changecollumname
  • Loading branch information
holema authored Mar 24, 2021
2 parents 3ce8eeb + b395325 commit dd3e081
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Command/ConnectServerAndGroupsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function __construct(string $name = null, EntityManagerInterface $entityM
protected function configure()
{
$this
->setDescription('This connects a yecloak Group with a server. Please add the server-Id, which can be found in the database and the keycloakgroup with two leading // (//all) ')
->setDescription('This connects a kecloak Group or a emaildomain with a server. Please add the server-Id, which can be found in the database and the keycloakgroup (on windows machines you need two leading /all --> //all) or the domain of an email (info@example.com --> example.com)')
->addArgument('serverId', InputArgument::REQUIRED, 'This is the Server Id to connect to the keycloak Group')
->addArgument('keycloakGroup', InputArgument::REQUIRED, 'This is the keycloak Group. Alle members of this group can use the server to create Rooms');
->addArgument('keycloakGroup', InputArgument::REQUIRED, 'This is the keycloak Group or email domain. Alle members of this group can use the server to create Rooms');
;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Command/RemoveServerAndGroupsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function __construct(string $name = null, EntityManagerInterface $entityM
protected function configure()
{
$this
->setDescription('This removes a yecloak Group connection from a server. Please add the server-Id, which can be found in the database and the keycloakgroup with two leading // (//all) ')
->setDescription('This removes a yecloak Group or a emaildomain connection from a server. Please add the server-Id, which can be found in the database and the keycloakgroup (on windows machines you need two leading /all --> //all) or the emaildomain')
->addArgument('serverId', InputArgument::REQUIRED, 'This is the Server Id to connect to the keycloak Group')
->addArgument('keycloakGroup', InputArgument::REQUIRED, 'This is the keycloak Group. Alle members of this group can use the server to create Rooms');
->addArgument('keycloakGroup', InputArgument::REQUIRED, 'This is the keycloak Group or the email domain. Alle members of this group or domain can use the server to create Rooms');
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class User extends BaseUser
private $subscribers;

/**
* @ORM\Column(type="array", nullable=true)
* @ORM\Column(type="array", nullable=true,name="keycloakGroup")
*/
private $groups = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Migrations/Version20210319080703.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function getDescription() : string
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE fos_user ADD groups LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
$this->addSql('ALTER TABLE fos_user ADD `groups` LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE fos_user DROP groups');
$this->addSql('ALTER TABLE fos_user DROP `groups` ');
}
}
31 changes: 31 additions & 0 deletions src/Migrations/Version20210324074357.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210324074357 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE fos_user CHANGE `groups` keycloakGroup LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE fos_user CHANGE keycloakgroup `groups` LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:array)\'');
}
}
10 changes: 10 additions & 0 deletions src/Service/ServerUserManagment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace App\Service;


use App\Entity\EmailDomainsToServers;
use App\Entity\KeycloakGroupsToServers;
use App\Entity\Server;
use App\Entity\User;
Expand Down Expand Up @@ -45,6 +46,15 @@ public function getServersFromUser(User $user)
}
}
}

$domain = explode('@', $user->getEmail())[1];
$tmpE = $this->em->getRepository(KeycloakGroupsToServers::class)->findBy(array('keycloakGroup' =>$domain ));
foreach ($tmpE as $data2) {
if (!in_array($data2->getServer(), $servers)) {
$servers[] = $data2->getServer();
}
}

return $servers;
}
}

0 comments on commit dd3e081

Please sign in to comment.