fixed some issue for the token authorization #87
| @ -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); | ||||
|     } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	
Dans le dernier pr j'ai fait un petit changement au cross origin. Pour l'instant c'est bon mais c'est juste pour attirer l'attention sur ça !