add user to organization
This commit is contained in:
parent
889010b5ad
commit
eaff14acc6
|
|
@ -154,11 +154,11 @@ class UserController extends AbstractController
|
|||
$user = new User();
|
||||
$form = $this->createForm(UserForm::class, $user);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$orgId = $request->get('organizationId');
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$orgId = $request->query->get('organizationId');
|
||||
// Handle file upload
|
||||
|
||||
// Handle file upload
|
||||
$picture = $form->get('pictureUrl')->getData();
|
||||
|
||||
if ($picture) {
|
||||
|
|
@ -166,6 +166,8 @@ class UserController extends AbstractController
|
|||
}else{
|
||||
$user->setPictureUrl("");
|
||||
}
|
||||
//FOR TEST PURPOSES, SETTING A DEFAULT RANDOM PASSWORD
|
||||
$user->setPassword($this->userService->generateRandomPassword());
|
||||
if ($orgId) {
|
||||
$org = $this->entityManager->getRepository(Organizations::class)->find($orgId);
|
||||
if ($org) {
|
||||
|
|
@ -173,13 +175,12 @@ class UserController extends AbstractController
|
|||
$uo->setUsers($user);
|
||||
$uo->setOrganization($org);
|
||||
$this->entityManager->persist($uo);
|
||||
$this->actionService->createAction("Create new user", $user, $orgId, $user->getUserIdentifier()." for organization ".$org->getName());
|
||||
$this->actionService->createAction("Create new user", $user, $org, "Added user to organization". $user->getUserIdentifier()." for organization ".$org->getName());
|
||||
}
|
||||
}
|
||||
|
||||
$this->actionService->createAction("Create new user", $actingUser, null, $user->getUserIdentifier());
|
||||
|
||||
//FOR TEST PURPOSES, SETTING A DEFAULT RANDOM PASSWORD
|
||||
$user->setPassword($this->userService->generateRandomPassword());
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
|
@ -189,6 +190,7 @@ class UserController extends AbstractController
|
|||
return $this->render('user/new.html.twig', [
|
||||
'user' => $user,
|
||||
'form' => $form->createView(),
|
||||
'organizationId' => $orgId
|
||||
]);
|
||||
}
|
||||
throw $this->createAccessDeniedException(self::ACCESS_DENIED);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
{{ form_widget(form) }}
|
||||
{% if organizationId is defined %}
|
||||
<div class="form-group">
|
||||
<input hidden type="text" value="{{ organizationId }}" name="organization_id">
|
||||
<input hidden type="text" value="{{ organizationId }}" name="organizationId">
|
||||
</div>
|
||||
{% endif %}
|
||||
<button type="submit" class="btn btn-primary">Enregistrer</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue