diff --git a/src/main/java/fr/eni/enchere/controllers/LanguageController.java b/src/main/java/fr/eni/enchere/controllers/LanguageController.java index 7ae9266..713c8e7 100644 --- a/src/main/java/fr/eni/enchere/controllers/LanguageController.java +++ b/src/main/java/fr/eni/enchere/controllers/LanguageController.java @@ -7,19 +7,22 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.support.RequestContextUtils; import java.util.Locale; @Controller public class LanguageController { + private final LocaleResolver localeResolver; + + public LanguageController(LocaleResolver localeResolver) { + this.localeResolver = localeResolver; + } @GetMapping("/change-language") - public String changeLanguage(HttpServletRequest request, HttpServletResponse response, @RequestParam("lang") String lang, @RequestHeader String referer) { - LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); - if (localeResolver != null) { - localeResolver.setLocale(request, response, new Locale(lang)); - } - return "redirect:" + referer; + public String changeLanguage(@RequestParam("lang") String lang, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + localeResolver.setLocale(request, response, Locale.forLanguageTag(lang)); + return "redirect:/"; // Redirect to a specific page or the current one } } diff --git a/src/main/java/fr/eni/enchere/security/WebSecurityConfig.java b/src/main/java/fr/eni/enchere/security/WebSecurityConfig.java index 507b63d..d956a97 100644 --- a/src/main/java/fr/eni/enchere/security/WebSecurityConfig.java +++ b/src/main/java/fr/eni/enchere/security/WebSecurityConfig.java @@ -18,12 +18,15 @@ public class WebSecurityConfig{ http.authorizeHttpRequests((requests) -> requests .requestMatchers("/", "/accueil").permitAll() .requestMatchers("/accueil", "/login", "/inscription/**", "/searchArticle", "/article/**", "/change-language").permitAll() - .requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**").permitAll() + .requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**", "/i18n/**").permitAll() .requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated() .requestMatchers("/admin").hasRole("ADMIN") .anyRequest().authenticated()) - .formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true)) - .logout((logout) -> logout.clearAuthentication(true).invalidateHttpSession(true) + .formLogin((form) -> form + .loginPage("/login") + .defaultSuccessUrl("/", true)) + .logout((logout) -> logout + .clearAuthentication(true).invalidateHttpSession(true) .deleteCookies("JSESSIONID").logoutSuccessUrl("/login?logout") .logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll()); diff --git a/src/main/resources/i18n/messages_en.properties b/src/main/resources/i18n/messages_en.properties index 9de4ea6..e448537 100644 --- a/src/main/resources/i18n/messages_en.properties +++ b/src/main/resources/i18n/messages_en.properties @@ -1 +1,44 @@ -accueil.search.title = Search for an article by name... \ No newline at end of file +home.search.title = Search for an item by name... +home.search.cat = All categories +home.search.button = Search + +profile.title = My Profile +profile.button = Edit +profile.pseudo = Username: +profile.surname = First Name: +profile.name = Last Name: +profile.email = Email: +profile.phone = Phone: +profile.street = Street: +profile.postal = Zip Code: +profile.city = City: +profile.credit = Credits: + +edit.profile.currentpassword = Current Password: +edit.profile.newpassword = New Password: +edit.profile.confirmnewpassword = Confirm New Password: +edit.profile.title = Edit My Profile +edit.profile.button.edit = Save Changes +edit.profile.button.del = Delete My Account + +login.title = To Log In: +login.id = Username: +login.password = Password: +login.save = Remember Me +login.forgotpassword = Forgot Password +login.connection = Login +login.makecompte = Create Account + +register.title = My Profile +register.button = Edit +register.pseudo = Username: +register.surname = First Name: +register.name = Last Name: +register.email = Email: +register.phone = Phone: +register.street = Street: +register.postal = Zip Code: +register.city = City: +register.credit = Credits: +register.make = create +register.cancel = cancel \ No newline at end of file diff --git a/src/main/resources/templates/accueil.html b/src/main/resources/templates/accueil.html index 8b0f2b1..b88f0bf 100644 --- a/src/main/resources/templates/accueil.html +++ b/src/main/resources/templates/accueil.html @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/templates/admin.html b/src/main/resources/templates/admin.html index 900f3af..be851f1 100644 --- a/src/main/resources/templates/admin.html +++ b/src/main/resources/templates/admin.html @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/templates/article.html b/src/main/resources/templates/article.html index 663fbfa..119c949 100644 --- a/src/main/resources/templates/article.html +++ b/src/main/resources/templates/article.html @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/templates/editProfil.html b/src/main/resources/templates/editProfil.html index a6f2ba4..7f0b5dd 100644 --- a/src/main/resources/templates/editProfil.html +++ b/src/main/resources/templates/editProfil.html @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/templates/inscription.html b/src/main/resources/templates/inscription.html index 9278e53..af30f07 100644 --- a/src/main/resources/templates/inscription.html +++ b/src/main/resources/templates/inscription.html @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/templates/modele-page.html b/src/main/resources/templates/modele-page.html index 5bcd680..a1241d9 100644 --- a/src/main/resources/templates/modele-page.html +++ b/src/main/resources/templates/modele-page.html @@ -38,12 +38,14 @@ S'inscrire / Se connecter @@ -101,6 +103,7 @@ © 2024 Copyright: + \ No newline at end of file diff --git a/src/main/resources/templates/profil.html b/src/main/resources/templates/profil.html index 1cb40a1..0338c19 100644 --- a/src/main/resources/templates/profil.html +++ b/src/main/resources/templates/profil.html @@ -1,5 +1,5 @@ - +