Skip to content

Commit

Permalink
[user admin] : fix some bl
Browse files Browse the repository at this point in the history
  • Loading branch information
julkwel committed Feb 21, 2021
1 parent 18820dd commit cc30867
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/Command/SekolikoCreateSuperAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$username = $helper->ask($input, $output, new Question('Login : '));
$passWord = $helper->ask($input, $output, new Question('Mots de passe : '));

$user = $this->manager->getRepository(User::class)->findBy(['username' => $username]);

if ($user) {
$io->error('User already exist !');
exit(1);
}

$user = new User();
$user
->setUsername($username)
Expand Down
19 changes: 10 additions & 9 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace App\Entity;

use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -161,7 +162,7 @@ public function getUsername(): ?string
*/
public function setUsername(string $username): self
{
$this->username = $username;
$this->username = mb_strtolower($username);

return $this;
}
Expand Down Expand Up @@ -254,19 +255,19 @@ public function getSchoolYear()
}

/**
* @return \DateTimeInterface|null
* @return DateTimeInterface|null
*/
public function getDateCreate(): ?\DateTimeInterface
public function getDateCreate(): ?DateTimeInterface
{
return $this->dateCreate;
}

/**
* @param \DateTimeInterface|null $dateCreate
* @param DateTimeInterface|null $dateCreate
*
* @return User
*/
public function setDateCreate(?\DateTimeInterface $dateCreate): self
public function setDateCreate(?DateTimeInterface $dateCreate): self
{
$this->dateCreate = $dateCreate;

Expand Down Expand Up @@ -553,19 +554,19 @@ public function removeHistory(History $history): self
}

/**
* @return \DateTimeInterface|null
* @return DateTimeInterface|null
*/
public function getBirthDate(): ?\DateTimeInterface
public function getBirthDate(): ?DateTimeInterface
{
return $this->birthDate;
}

/**
* @param \DateTimeInterface|null $birthDate
* @param DateTimeInterface|null $birthDate
*
* @return User
*/
public function setBirthDate(?\DateTimeInterface $birthDate): self
public function setBirthDate(?DateTimeInterface $birthDate): self
{
$this->birthDate = $birthDate;

Expand Down

0 comments on commit cc30867

Please sign in to comment.