cookie -> authorization
This commit is contained in:
parent
d3303749f8
commit
1ad67edabb
@ -10,7 +10,6 @@ import ovh.herisson.Clyde.Tables.Token;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
|
||||
public class TokenController {
|
||||
|
||||
private final TokenService tokenServ;
|
||||
|
@ -23,14 +23,10 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/user")
|
||||
public ResponseEntity<User> getUser(@RequestHeader("Cookie") String cookie){
|
||||
String[] tokens = cookie.split("=",2);
|
||||
if (! tokens[0].equals("session_token") || tokens[1].length() != 64)
|
||||
{
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
System.out.println(tokens[1]);
|
||||
User user = authServ.getUserFromToken(tokens[1]);
|
||||
public ResponseEntity<User> getUser(@RequestHeader("Cookie") String authorization){
|
||||
|
||||
if (authorization == null) return new UnauthorizedResponse<>(null);
|
||||
User user = authServ.getUserFromToken(authorization);
|
||||
if (user == null) return new UnauthorizedResponse<>(null);
|
||||
return new ResponseEntity<>(user, HttpStatus.OK);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user