diff --git a/migrations/Version20251013133256.php b/migrations/Version20251013133256.php
new file mode 100644
index 0000000..57b356a
--- /dev/null
+++ b/migrations/Version20251013133256.php
@@ -0,0 +1,32 @@
+addSql('ALTER TABLE "user" ALTER picture_url DROP NOT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('CREATE SCHEMA public');
+ $this->addSql('ALTER TABLE "user" ALTER picture_url SET NOT NULL');
+ }
+}
diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php
index f8ea70f..d27a371 100644
--- a/src/Controller/UserController.php
+++ b/src/Controller/UserController.php
@@ -10,6 +10,7 @@ use App\Entity\UserOrganizatonApp;
use App\Entity\UsersOrganizations;
use App\Form\UserForm;
use App\Service\ActionService;
+use App\Service\AwsService;
use App\Service\UserOrganizationAppService;
use App\Service\UserOrganizationService;
use App\Service\UserService;
@@ -30,7 +31,9 @@ class UserController extends AbstractController
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly UserService $userService,
- private readonly ActionService $actionService, private readonly UserOrganizationAppService $userOrganizationAppService, private readonly UserOrganizationService $userOrganizationService,
+ private readonly ActionService $actionService,
+ private readonly UserOrganizationAppService $userOrganizationAppService,
+ private readonly UserOrganizationService $userOrganizationService,
)
{
}
@@ -172,9 +175,10 @@ class UserController extends AbstractController
if ($picture) {
$this->userService->handleProfilePicture($user, $picture);
- } else {
- $user->setPictureUrl("");
}
+// else {
+// $user->setPictureUrl("");
+// }
//FOR TEST PURPOSES, SETTING A DEFAULT RANDOM PASSWORD
$user->setPassword($this->userService->generateRandomPassword());
if ($orgId) {
diff --git a/src/Entity/User.php b/src/Entity/User.php
index 910ccb2..6d3ad6e 100644
--- a/src/Entity/User.php
+++ b/src/Entity/User.php
@@ -46,7 +46,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\Column(options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?\DateTimeImmutable $createdAt = null;
- #[ORM\Column(length: 255)]
+ #[ORM\Column(length: 255, nullable: true)]
private ?string $pictureUrl = null;
#[ORM\Column(options: ['default' => 'CURRENT_TIMESTAMP'])]
diff --git a/src/Service/UserService.php b/src/Service/UserService.php
index 6297c14..6620c46 100644
--- a/src/Service/UserService.php
+++ b/src/Service/UserService.php
@@ -8,6 +8,7 @@ use App\Entity\Roles;
use App\Entity\User;
use App\Entity\UserOrganizatonApp;
use App\Entity\UsersOrganizations;
+use App\Service\AwsService;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityNotFoundException;
@@ -26,7 +27,7 @@ class UserService
public function __construct(private readonly EntityManagerInterface $entityManager,
private readonly Security $security,
- string $profileDirectory
+ string $profileDirectory, private readonly AwsService $awsService
)
{
$this->profileDirectory = $profileDirectory;
@@ -246,25 +247,32 @@ class UserService
// Create custom filename: userNameUserSurname_ddmmyyhhmmss
$customFilename = $user->getName() . $user->getSurname() . '_' . date('dmyHis') . '.' . $extension;
+ try{
+ $this->awsService->PutDocObj($_ENV['S3_PORTAL_BUCKET'], $picture, $customFilename , $extension, 'profile/');
- // Define upload directory
- $uploadDirectory = $this->profileDirectory;
- // Create directory if it doesn't exist
- if (!is_dir($uploadDirectory) && !mkdir($uploadDirectory, 0755, true) && !is_dir($uploadDirectory)) {
- throw new DirectoryCouldNotBeCreatedException(sprintf('Directory "%s" was not created', $uploadDirectory));
- }
- try {
-
- // Move the file to the upload directory
- $picture->move($uploadDirectory, $customFilename);
-
- // Update user entity with the file path (relative to public directory)
- $user->setPictureUrl('uploads/profile/' . $customFilename);
-
+ $user->setPictureUrl('profile/'.$customFilename);
} catch (FileException $e) {
// Handle upload error
throw new FileException('File upload failed: ' . $e->getMessage());
}
+
+
+
+// // Define upload directory
+// $uploadDirectory = $this->profileDirectory;
+// // Create directory if it doesn't exist
+// if (!is_dir($uploadDirectory) && !mkdir($uploadDirectory, 0755, true) && !is_dir($uploadDirectory)) {
+// throw new DirectoryCouldNotBeCreatedException(sprintf('Directory "%s" was not created', $uploadDirectory));
+// }
+// try {
+//
+// // Move the file to the upload directory
+// $picture->move($uploadDirectory, $customFilename);
+//
+// // Update user entity with the file path (relative to public directory)
+// $user->setPictureUrl('uploads/profile/' . $customFilename);
+//
+//
}
/**
diff --git a/templates/elements/navbar.html.twig b/templates/elements/navbar.html.twig
index b202cdc..e467cf8 100644
--- a/templates/elements/navbar.html.twig
+++ b/templates/elements/navbar.html.twig
@@ -64,7 +64,12 @@
{{ app.user.email|first|capitalize }} {{ app.user.email|first|capitalize }}#}
+{# {% else %}#}
+