diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index 787a534..6d5110e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -12,7 +12,7 @@ import java.util.Arrays; import java.util.Date; @RestController -@CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(originPatterns = "*", allowCredentials = "true") public class MockController { private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/PingController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/PingController.java index f0f26d3..b1148bf 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/PingController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/PingController.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RestController; import ovh.herisson.Clyde.Responses.PingResponse; @RestController -@CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(originPatterns = "*", allowCredentials = "true") public class PingController { @GetMapping("/ping") diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/StorageController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/StorageController.java index 2a36657..724ae10 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/StorageController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/StorageController.java @@ -1,16 +1,15 @@ package ovh.herisson.Clyde.EndPoints; -import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import ovh.herisson.Clyde.Services.StorageService; -import org.springframework.core.io.Resource; import ovh.herisson.Clyde.Tables.FileType; +import ovh.herisson.Clyde.Tables.StorageFile; @RestController -@CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(originPatterns = "*", allowCredentials = "true") public class StorageController { private final StorageService storageServ; @@ -21,12 +20,17 @@ public class StorageController { @PostMapping("/upload/{fileType}") - public ResponseEntity handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable FileType fileType) { + public ResponseEntity handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable FileType fileType) { - String path = storageServ.store(file,fileType); + StorageFile fileEntry = null; + try { + fileEntry = storageServ.store(file,fileType); + + } catch(Exception e){ + e.printStackTrace(); + } - if (path == null) return new ResponseEntity<>("issue with the file storage", HttpStatus.BAD_REQUEST); - return new ResponseEntity<>(path, HttpStatus.OK); + return new ResponseEntity<>(fileEntry, HttpStatus.OK); } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/TokenController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/TokenController.java index 793e61b..ba07fca 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/TokenController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/TokenController.java @@ -9,7 +9,7 @@ import ovh.herisson.Clyde.Services.TokenService; import ovh.herisson.Clyde.Tables.Token; @RestController -@CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(originPatterns = "*", allowCredentials = "true") public class TokenController { private final TokenService tokenServ; diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java index 43bcd0c..df306ff 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -12,7 +12,7 @@ import ovh.herisson.Clyde.Tables.User; @RestController -@CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(originPatterns = "*", allowCredentials = "true") public class UserController { private final UserService userService; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java index c73dd0b..fcc5102 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java @@ -27,7 +27,7 @@ public class StorageService { } - public String store(MultipartFile file, FileType fileType) { + public StorageFile store(MultipartFile file, FileType fileType) { if (file.getOriginalFilename().isEmpty()){return null;} @@ -49,9 +49,7 @@ public class StorageService { String url = this.rootLocation.resolve(Paths.get(Objects.requireNonNull(stringUuid))) .normalize().toString(); - fileRepo.save(new StorageFile(file.getName(),url, fileType)); - - return url; + return fileRepo.save(new StorageFile(file.getName(),url, fileType)); } public void delete(StorageFile file) throws SecurityException { diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 1927230..4bd8fb0 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -1,7 +1,9 @@ @@ -99,6 +103,10 @@

{{i18n("login.guest.country")}}

+
+

ProfilePicture

+ +

CURSUS