Log action

This commit is contained in:
Charles 2025-09-04 09:11:37 +02:00
parent 0bcab27a1d
commit 3ca5eea877
3 changed files with 17 additions and 8 deletions

View File

@ -132,14 +132,22 @@ class UserController extends AbstractController
$user->setModifiedAt(new \DateTimeImmutable('now')); $user->setModifiedAt(new \DateTimeImmutable('now'));
$this->entityManager->persist($user); $this->entityManager->persist($user);
$this->entityManager->flush(); $this->entityManager->flush();
if ($request->get('organizationId')) {
$org = $this->entityManager->getRepository(Organizations::class)->find($request->get('organizationId'));
if ($org) {
$this->actionService->createAction("Edit user information", $actingUser, $org, $user->getUserIdentifier());
}
} else {
$this->actionService->createAction("Edit user information", $actingUser, null, $user->getUserIdentifier()); $this->actionService->createAction("Edit user information", $actingUser, null, $user->getUserIdentifier());
}
return $this->redirectToRoute('user_show', ['id' => $user->getId()]); return $this->redirectToRoute('user_show', ['id' => $user->getId(), 'organizationId' => $request->get('organizationId')]);
} }
return $this->render('user/edit.html.twig', [ return $this->render('user/edit.html.twig', [
'user' => $user, 'user' => $user,
'form' => $form->createView(), 'form' => $form->createView(),
'organizationId' => $request->get('organizationId')
]); ]);
} }
throw $this->createAccessDeniedException(self::ACCESS_DENIED); throw $this->createAccessDeniedException(self::ACCESS_DENIED);

View File

@ -11,6 +11,7 @@
{{ form_start(form, {'action': path('user_edit', {'id': user.id}), 'method': 'PUT'}) }} {{ form_start(form, {'action': path('user_edit', {'id': user.id}), 'method': 'PUT'}) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<input hidden type="text" value="{{ organizationId }}" name="organizationId">
<button type="submit" class="btn btn-primary">Enregistrer</button> <button type="submit" class="btn btn-primary">Enregistrer</button>
{{ form_end(form) }} {{ form_end(form) }}
</div> </div>

View File

@ -24,7 +24,7 @@
</form> </form>
{% endif %} {% endif %}
{% endif %} {% endif %}
<a href="{{ path('user_edit', {'id': user.id}) }}" class="btn btn-primary">Modifier</a> <a href="{{ path('user_edit', {'id': user.id, 'organizationId': organizationId}) }}" class="btn btn-primary">Modifier</a>
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">