rescue old vm stuff

This commit is contained in:
2022-11-05 17:18:04 +01:00
parent e17cf3eaeb
commit 219f4097ff
17 changed files with 1405 additions and 1617 deletions

View File

@@ -21,7 +21,7 @@ class UserController extends BaseController
{
#[Route(path: '/profile/edit/{username}', name: 'app_profile_edit')]
public function editProfile(Request $request, UserRepository $userRepository, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, string $username = ''): Response
public function editProfile(Request $request, UserRepository $userRepository, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, string $username = ''): Response
{
if ($username !== '') {
if ($this->isGranted(attribute: 'ROLE_ADMIN')) {
@@ -29,7 +29,7 @@ class UserController extends BaseController
'username' => $username,
]);
} else {
throw new AccessDeniedException(message: 'Only admins are allowed to edit Profiles.');
throw new AccessDeniedException(message: 'Only admins are allowed to edit foreign profiles.');
}
} else {
$user = $this->getUser();
@@ -43,12 +43,12 @@ class UserController extends BaseController
// if there's a new password, use it
if ($form->get(name: 'newPassword')->getData())
$user->setPassword(
password: $userPasswordHasher->hashPassword(
user: $user,
plainPassword: $form->get(name: 'newPassword')->getData()
)
);
$user->setPassword(
password: $userPasswordHasher->hashPassword(
user: $user,
plainPassword: $form->get(name: 'newPassword')->getData()
)
);
$entityManager->persist(entity: $user);
$entityManager->flush();
@@ -64,14 +64,9 @@ class UserController extends BaseController
'user' => $user,
'userForm' => $form
]);
if (isset($user)) {
} else {
throw new UserNotFoundException();
}
}
#[Route(path: '/profile/{username}', name: 'app_profile')]
public function showProfile(UserRepository $userRepository, string $username = ''): Response
{
@@ -84,7 +79,7 @@ class UserController extends BaseController
]);
}
return $this->render(view: 'user/show_profile.html.twig', parameters: [
return $this->render(view: '@default/user/show_profile.html.twig', parameters: [
'user' => $user,
]);
}
@@ -94,7 +89,7 @@ class UserController extends BaseController
{
$users = $userRepository->findAll();
return $this->render(view: 'user/list_users.html.twig', parameters: [
return $this->render(view: '@default/user/list_users.html.twig', parameters: [
'users' => $users,
]);
}