format user data on form submit
This commit is contained in:
parent
c673fcd83b
commit
d8934e2cf5
|
|
@ -176,11 +176,9 @@ class UserController extends AbstractController
|
|||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
// Handle file upload
|
||||
$picture = $form->get('pictureUrl')->getData();
|
||||
|
||||
if ($picture) {
|
||||
$this->userService->handleProfilePicture($user, $picture);
|
||||
}
|
||||
$picture = $form->get('pictureUrl')->getData();
|
||||
$this->userService->formatNewUserData($user, $picture);
|
||||
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
|
|
@ -240,7 +238,7 @@ class UserController extends AbstractController
|
|||
|
||||
// Handle file upload
|
||||
$picture = $form->get('pictureUrl')->getData();
|
||||
$this->userService->formatNewUserData($user, $picture);
|
||||
$this->userService->formatNewUserData($user, $picture, true);
|
||||
|
||||
if ($orgId) {
|
||||
$uo = new UsersOrganizations();
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ class UserService
|
|||
* @param User $user
|
||||
* @return void
|
||||
*/
|
||||
public function formatNewUserData(User $user, $picture): void
|
||||
public function formatNewUserData(User $user, $picture, bool $setPassword = false): void
|
||||
{
|
||||
// capitalize name and surname
|
||||
$user->setName(ucfirst(strtolower($user->getName())));
|
||||
|
|
@ -470,10 +470,11 @@ class UserService
|
|||
$user->setName(trim($user->getName()));
|
||||
$user->setSurname(trim($user->getSurname()));
|
||||
$user->setEmail(trim($user->getEmail()));
|
||||
if($setPassword) {
|
||||
//FOR SETTING A DEFAULT RANDOM PASSWORD OF 50 CHARACTERS until user set his own password
|
||||
$user->setPassword($this->generateRandomPassword());
|
||||
|
||||
//FOR SETTING A DEFAULT RANDOM PASSWORD OF 50 CHARACTERS until user set his own password
|
||||
$user->setPassword($this->generateRandomPassword());
|
||||
|
||||
}
|
||||
if($picture) {
|
||||
$this->handleProfilePicture($user, $picture);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue