1
0
forked from PGL/Clyde

ups je change un copié collé

This commit is contained in:
Bartha Maxime 2024-03-13 19:14:22 +01:00
parent 4241f15731
commit 157e5951fc

View File

@ -2,6 +2,7 @@ package ovh.herisson.Clyde.EndPoints;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
@ -49,19 +50,9 @@ public class LoginController {
@PostMapping("/register") @PostMapping("/register")
public ResponseEntity<String> register(@RequestBody InscriptionRequest inscriptionRequest){ public ResponseEntity<String> register(@RequestBody InscriptionRequest inscriptionRequest){
authServ.register(inscriptionRequest); authServ.register(inscriptionRequest);
return new ResponseEntity<>("Is OK", HttpStatus.OK);
String sessionToken = authServ.login();
if (sessionToken == null){
return new UnauthorizedResponse<>("Identifier or Password incorrect");
}
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Set-Cookie",String.format("session_token=%s",sessionToken));
return ResponseEntity.ok().headers(responseHeaders).build();
} }
} }