优化鉴权,优化获取联系人
This commit is contained in:
@@ -39,21 +39,12 @@ public class ContactController {
|
||||
|
||||
@PostMapping("/user_add_contact")
|
||||
public Result userAddContact(
|
||||
@RequestHeader("Authorization") String authHeader, @RequestHeader("Device-ID") String deviceId,
|
||||
@RequestParam(value = "user_id") String userId, @RequestParam(value = "sn") String sn,
|
||||
@RequestParam(value = "user_id") String userId,
|
||||
@RequestParam(value = "sn") String sn,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@RequestPart("contact_json") String jsonData
|
||||
) throws JsonProcessingException {
|
||||
|
||||
if (!authHeader.startsWith("Bearer ")) {
|
||||
return Result.error().message("Invalid Authorization header");
|
||||
}
|
||||
String token = authHeader.substring(7); // 去掉 "Bearer " 前缀
|
||||
|
||||
if (!jwtUtil.validateAccessToken(userId, token, deviceId)) {
|
||||
return Result.error().message("Invalid token");
|
||||
}
|
||||
|
||||
User user = userService.getUserByUserId(userId);
|
||||
if (user == null) {
|
||||
return Result.error().message("user not found");
|
||||
@@ -83,17 +74,8 @@ public class ContactController {
|
||||
|
||||
@GetMapping("/get_contacts")
|
||||
public Result getContacts(
|
||||
@RequestHeader("Authorization") String authHeader, @RequestHeader("Device-ID") String deviceId,
|
||||
@RequestParam(value = "user_id") String userId, @RequestParam(value = "sn") String sn
|
||||
) {
|
||||
if (!authHeader.startsWith("Bearer ")) {
|
||||
return Result.error().message("Invalid Authorization header");
|
||||
}
|
||||
String token = authHeader.substring(7); // 去掉 "Bearer " 前缀
|
||||
|
||||
if (!jwtUtil.validateAccessToken(userId, token, deviceId)) {
|
||||
return Result.error().message("Invalid token");
|
||||
}
|
||||
|
||||
User user = userService.getUserByUserId(userId);
|
||||
if (user == null) {
|
||||
|
||||
Reference in New Issue
Block a user