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()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
// Handle file upload
|
// Handle file upload
|
||||||
$picture = $form->get('pictureUrl')->getData();
|
|
||||||
|
|
||||||
if ($picture) {
|
$picture = $form->get('pictureUrl')->getData();
|
||||||
$this->userService->handleProfilePicture($user, $picture);
|
$this->userService->formatNewUserData($user, $picture);
|
||||||
}
|
|
||||||
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
||||||
$this->entityManager->persist($user);
|
$this->entityManager->persist($user);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
@ -240,7 +238,7 @@ class UserController extends AbstractController
|
||||||
|
|
||||||
// Handle file upload
|
// Handle file upload
|
||||||
$picture = $form->get('pictureUrl')->getData();
|
$picture = $form->get('pictureUrl')->getData();
|
||||||
$this->userService->formatNewUserData($user, $picture);
|
$this->userService->formatNewUserData($user, $picture, true);
|
||||||
|
|
||||||
if ($orgId) {
|
if ($orgId) {
|
||||||
$uo = new UsersOrganizations();
|
$uo = new UsersOrganizations();
|
||||||
|
|
|
||||||
|
|
@ -460,7 +460,7 @@ class UserService
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function formatNewUserData(User $user, $picture): void
|
public function formatNewUserData(User $user, $picture, bool $setPassword = false): void
|
||||||
{
|
{
|
||||||
// capitalize name and surname
|
// capitalize name and surname
|
||||||
$user->setName(ucfirst(strtolower($user->getName())));
|
$user->setName(ucfirst(strtolower($user->getName())));
|
||||||
|
|
@ -470,10 +470,11 @@ class UserService
|
||||||
$user->setName(trim($user->getName()));
|
$user->setName(trim($user->getName()));
|
||||||
$user->setSurname(trim($user->getSurname()));
|
$user->setSurname(trim($user->getSurname()));
|
||||||
$user->setEmail(trim($user->getEmail()));
|
$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) {
|
if($picture) {
|
||||||
$this->handleProfilePicture($user, $picture);
|
$this->handleProfilePicture($user, $picture);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue