Merge branch 'Johan'
This commit is contained in:
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import fr.eni.enchere.security.LoginService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.commons.validator.routines.EmailValidator;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -36,15 +37,17 @@ public class InscriptionController {
|
||||
|
||||
@Autowired
|
||||
private final UserService userService;
|
||||
private LoginService loginService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private EmailValidator emailValidator;
|
||||
private PhoneNumberUtil phoneValidator;
|
||||
|
||||
public InscriptionController(UserService userService, PasswordEncoder passwordEncoder, EmailValidator emailValidator, PhoneNumberUtil phoneValidator) {
|
||||
public InscriptionController(UserService userService, PasswordEncoder passwordEncoder, EmailValidator emailValidator, PhoneNumberUtil phoneValidator, LoginService loginService) {
|
||||
this.userService = userService;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.emailValidator = emailValidator;
|
||||
this.phoneValidator = phoneValidator;
|
||||
this.loginService = loginService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@@ -137,11 +140,6 @@ public class InscriptionController {
|
||||
}
|
||||
// Sinon, enregistrer l'utilisateur et rediriger vers la page de connexion
|
||||
userService.setUtilisateur(userProfile);
|
||||
// Dans votre méthode setUser après la validation réussie
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromPath("/login/register");
|
||||
builder.queryParam("username", userProfile.getPseudo());
|
||||
builder.queryParam("password", userProfile.getPassword());
|
||||
// Rediriger vers la méthode POST de /login avec les paramètres
|
||||
return "redirect:" + builder.toUriString();
|
||||
return "redirect:/enchere";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,8 @@ public class LoginController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String login(@RequestParam("username") String username, @RequestParam("password") String password,
|
||||
@RequestParam(value = "username", required = false) String usernameByRegister,
|
||||
@RequestParam(value = "password", required = false) String passwordByRegister) {
|
||||
public String login(@RequestParam("username") String username, @RequestParam("password") String password) {
|
||||
UserProfil user = userService.utilisateurByName(username);
|
||||
UserProfil userRegister = userService.utilisateurByName(usernameByRegister);
|
||||
if (user != null && user.getPassword().equals(password)) {
|
||||
return "redirect:/enchere";
|
||||
} else {
|
||||
@@ -46,16 +43,4 @@ public class LoginController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public String login(@RequestParam(value = "username", required = true) String usernameByRegister,
|
||||
@RequestParam(value = "password", required = true) String passwordByRegister) {
|
||||
UserProfil userRegister = userService.utilisateurByName(usernameByRegister);
|
||||
System.out.println(usernameByRegister);
|
||||
if (userRegister != null && userRegister.getPassword().equals(passwordByRegister)) {
|
||||
return "redirect:/enchere";
|
||||
} else {
|
||||
return "redirect:/security/login?error";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,8 +83,7 @@ public class ProfilController {
|
||||
UserProfil userProfile = userService.utilisateurByName(username);
|
||||
//Supprimer le compte
|
||||
userService.deleteUtilisateur(userProfile.getId());
|
||||
//ATTENTION AJOUTER LA DECONNEXION
|
||||
return "redirect:/enchere";
|
||||
return "redirect:/logout";
|
||||
}
|
||||
|
||||
@PostMapping("/updateUser")
|
||||
|
||||
Reference in New Issue
Block a user