Skip to content
Snippets Groups Projects
Commit 08155db9 authored by Paul Cancel's avatar Paul Cancel
Browse files

Correctifs pour IUT

parent 0b25d103
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 7 deletions
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version> <version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/>
</parent> </parent>
<groupId>fr.but.infoetu</groupId> <groupId>fr.but.infoetu</groupId>
<artifactId>meetingplannr</artifactId> <artifactId>meetingplannr</artifactId>
......
package fr.but.infoetu.meetingplannr.controller;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/images")
public class ImageController {
private final String UPLOAD_DIR = "src/main/resources/static/uploads/";
@GetMapping("/{filename}")
public ResponseEntity<byte[]> getImage(@PathVariable String filename) {
try {
Path imagePath = Paths.get(UPLOAD_DIR, filename);
byte[] imageBytes = Files.readAllBytes(imagePath);
String mimeType = Files.probeContentType(imagePath);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "inline;filename=\"" + filename + "\"")
.contentType(MediaType.parseMediaType(mimeType))
.body(imageBytes);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
}
}
...@@ -31,6 +31,7 @@ import fr.but.infoetu.meetingplannr.repository.MeetingRepository; ...@@ -31,6 +31,7 @@ import fr.but.infoetu.meetingplannr.repository.MeetingRepository;
import fr.but.infoetu.meetingplannr.repository.RequestRepository; import fr.but.infoetu.meetingplannr.repository.RequestRepository;
import fr.but.infoetu.meetingplannr.repository.UserRepository; import fr.but.infoetu.meetingplannr.repository.UserRepository;
import fr.but.infoetu.meetingplannr.service.UserService; import fr.but.infoetu.meetingplannr.service.UserService;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid; import jakarta.validation.Valid;
...@@ -62,8 +63,8 @@ public class UserController { ...@@ -62,8 +63,8 @@ public class UserController {
if (details == null) { if (details == null) {
return "redirect:/public/login"; return "redirect:/public/login";
} }
System.out.println(details);
User user = ur.findByUsername(details.getUsername()).get(); User user = ur.findByUsername(details.getUsername()).get();
System.out.println(user);
model.addAttribute("currentUser", user); model.addAttribute("currentUser", user);
return "user/profile"; return "user/profile";
} }
......
...@@ -78,7 +78,7 @@ public class User implements UserDetails { ...@@ -78,7 +78,7 @@ public class User implements UserDetails {
private String photoPath; private String photoPath;
public String getPhotoUrl() { public String getPhotoUrl() {
return photoPath != null ? "/uploads/" + photoPath : "/uploads/avatar.png"; return photoPath != null ? "/images/" + photoPath : "/images/avatar.png";
} }
@Override @Override
......
...@@ -46,7 +46,8 @@ public class UserService { ...@@ -46,7 +46,8 @@ public class UserService {
helper.setFrom("paul.cancel.etu@univ-lille.fr"); helper.setFrom("paul.cancel.etu@univ-lille.fr");
helper.setTo(user.getUsername()); helper.setTo(user.getUsername());
helper.setSubject("Compte banni"); helper.setSubject("Compte banni");
helper.setText("Votre compte : " + user.getUsername() + " a été banni le " + java.time.LocalDate.now()); helper.setText("Votre compte : " + user.getUsername() + " a été banni le " + java.time.LocalDate.now() + "\n"
+ "Vous ne pourrez plus vous connecter à MeetingPlannr à partir de maintenant.");
sender.send(message); sender.send(message);
} catch (jakarta.mail.MessagingException e) { } catch (jakarta.mail.MessagingException e) {
throw new RuntimeException("Erreur lors de l'envoi de l'email", e); throw new RuntimeException("Erreur lors de l'envoi de l'email", e);
......
...@@ -3,9 +3,13 @@ spring.mvc.view.prefix=/WEB-INF/jsp/ ...@@ -3,9 +3,13 @@ spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp spring.mvc.view.suffix=.jsp
spring.datasource.driverClassName=org.postgresql.Driver spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/but3 # spring.datasource.url=jdbc:postgresql://localhost:5432/but3
spring.datasource.username=postgres # spring.datasource.username=postgres
spring.datasource.password=admin # spring.datasource.password=admin
spring.datasource.url=jdbc:postgresql://psqlserv/but3
spring.datasource.username=paulcanceletu
spring.datasource.password=moi
spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.hibernate.ddl-auto=create-drop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment