cookie -> authorization
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m3s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 26s

This commit is contained in:
Bartha Maxime 2024-03-10 10:44:14 +01:00
parent d3303749f8
commit 1ad67edabb
2 changed files with 4 additions and 9 deletions

View File

@ -10,7 +10,6 @@ import ovh.herisson.Clyde.Tables.Token;
@RestController @RestController
@CrossOrigin(origins = "http://localhost:5173") @CrossOrigin(origins = "http://localhost:5173")
public class TokenController { public class TokenController {
private final TokenService tokenServ; private final TokenService tokenServ;

View File

@ -23,14 +23,10 @@ public class UserController {
} }
@GetMapping("/user") @GetMapping("/user")
public ResponseEntity<User> getUser(@RequestHeader("Cookie") String cookie){ public ResponseEntity<User> getUser(@RequestHeader("Cookie") String authorization){
String[] tokens = cookie.split("=",2);
if (! tokens[0].equals("session_token") || tokens[1].length() != 64) if (authorization == null) return new UnauthorizedResponse<>(null);
{ User user = authServ.getUserFromToken(authorization);
return new UnauthorizedResponse<>(null);
}
System.out.println(tokens[1]);
User user = authServ.getUserFromToken(tokens[1]);
if (user == null) return new UnauthorizedResponse<>(null); if (user == null) return new UnauthorizedResponse<>(null);
return new ResponseEntity<>(user, HttpStatus.OK); return new ResponseEntity<>(user, HttpStatus.OK);
} }