Skip to content

Commit ee61bc0

Browse files
committed
fix: readme file and token in header instead of body
Signed-off-by: Akash Jaiswal <akashjaiswal3846@gmail.com>
1 parent 4b8d6ca commit ee61bc0

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

spring-boot-jwt/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ The following API endpoints are available:
9494
- Verify
9595

9696
```bash
97-
curl --location --request POST 'http://localhost:8080/users/verify' \
98-
--header 'Content-Type: application/json' \
99-
--data-raw '{
100-
"token": "your_jwt_token_here"
101-
}'
97+
curl --location --request POST 'http://localhost:8080/users/tokenVerification' \
98+
--header 'Authorization: Bearer <your_jwt_token_here>'
99+
```
102100
```
103101
104102
#### TEST mode

spring-boot-jwt/src/main/java/com/akash/springboot/jwt/JwtUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public boolean validateToken(String token) {
3030
return true;
3131
} catch (SignatureException e) {
3232
return false;
33+
} catch (Exception e) {
34+
return false;
3335
}
3436
}
3537
}

spring-boot-jwt/src/main/java/com/akash/springboot/jwt/UserController.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,11 @@ public ResponseEntity<?> login(@RequestBody Map<String, String> user) {
4343
}
4444

4545
@PostMapping("/tokenVerification")
46-
public ResponseEntity<?> tokenAuthentication(@RequestBody Map<String, String> request) {
47-
String token = request.get("token");
48-
46+
public ResponseEntity<?> tokenAuthentication(@RequestHeader("Authorization") String token) {
4947
boolean isValid = jwtUtil.validateToken(token);
5048

5149
Map<String, Boolean> response = new HashMap<>();
5250
response.put("isValid", isValid);
53-
System.err.println(isValid);
5451
return new ResponseEntity<>(response, HttpStatus.OK);
5552
}
56-
}
53+
}

0 commit comments

Comments
 (0)