cookie -> authorization
This commit is contained in:
parent
d3303749f8
commit
1ad67edabb
@ -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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user