Skip to content
This repository was archived by the owner on Jan 10, 2026. It is now read-only.

Commit 7ef2266

Browse files
committed
add JWT
1 parent 2c7960e commit 7ef2266

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/org/example/springnewbie/Controller/UserController.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
@RestController
2323
@RequestMapping("/v1/user")
2424
public class UserController {
25-
@Autowired
26-
private UserService userService;
25+
// @Autowired
26+
// private UserService userService;
2727

28+
private static final UserService userService = new UserService();
29+
private static final JwtToken TOKEN = new JwtToken();
2830
private static final Gson GSON = new Gson();
2931

3032
@PostMapping("/post/login")
@@ -40,7 +42,7 @@ public ResponseEntity login(@RequestBody @Valid LoginUserDTO user) {
4042
}else if(!tempUser.getPassword().equals(user.getPassword())) {
4143
rsp.PASSWD_INCORRECT();
4244
}else {
43-
headers.set("token", JwtToken.generateToken(user.getName()));
45+
headers.set("token", TOKEN.generateToken(user.getName()));
4446
rsp.SUCCESS();
4547
}
4648

0 commit comments

Comments
 (0)