Skip to content

Commit

Permalink
Remove easyadmin file
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMendolia committed Sep 24, 2023
1 parent 8bce9c6 commit 9b08c38
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 49 deletions.
2 changes: 0 additions & 2 deletions src/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public function index(AuthenticationUtils $authenticationUtils): Response
// parameters usually defined in Symfony login forms
'error' => $error,
'last_username' => $lastUsername,


]);
}

Expand Down
22 changes: 17 additions & 5 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re
'help' => 'Required for new users',
]);


$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$plainPassword = $form->get('plainPassword')->getData();
if (!is_string($plainPassword)) {
throw new \RuntimeException('Password must be a string');
}
$user->setPassword($this->passwordHasher->hashPassword(
$user,
$form->get('plainPassword')->getData()
$plainPassword
));
$entityManager->persist($user);
$entityManager->flush();
Expand All @@ -66,10 +69,15 @@ public function edit(Request $request, User $user, EntityManagerInterface $entit
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
if ($form->get('plainPassword')->getData() !== null) {
$plainPassword = $form->get('plainPassword')->getData();

if ($plainPassword !== null) {
if (!is_string($plainPassword)) {
throw new \RuntimeException('Password must be a string');
}
$user->setPassword($this->passwordHasher->hashPassword(
$user,
$form->get('plainPassword')->getData()
$plainPassword
));
}

Expand All @@ -87,7 +95,11 @@ public function edit(Request $request, User $user, EntityManagerInterface $entit
#[Route('/{id}', name: 'app_user_delete', methods: ['POST'])]
public function delete(Request $request, User $user, EntityManagerInterface $entityManager): Response
{
if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->request->get('_token'))) {
$token = $request->request->get('_token');
if (!is_string($token)) {
throw new \RuntimeException('Token must be a string');
}
if ($this->isCsrfTokenValid('delete'.$user->getId(), $token)) {
$entityManager->remove($user);
$entityManager->flush();
}
Expand Down
41 changes: 0 additions & 41 deletions src/EventSubscriber/EasyAdminSubscriber.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function createMainMenu(array $options): ItemInterface

$user = $this->security->getUser();

if($this->security->isGranted('ROLE_ADMIN')) {
if ($this->security->isGranted('ROLE_ADMIN')) {
$menu->addChild('Admin', ['route' => 'app_user_index', ...$this->defaultAttr])->setExtra('icon', 'gear-fill');
}

Expand Down

0 comments on commit 9b08c38

Please sign in to comment.