适配JwtVerify注释
This commit is contained in:
parent
3641689cbb
commit
ad14782702
@ -2,6 +2,7 @@ package org.cmh.backend.authentication.controller;
|
||||
|
||||
|
||||
import org.cmh.backend.Utils.JwtUtil;
|
||||
import org.cmh.backend.Utils.JwtVerify;
|
||||
import org.cmh.backend.authentication.dto.*;
|
||||
import org.cmh.backend.authentication.model.UserHS;
|
||||
import org.cmh.backend.authentication.service.UserService;
|
||||
@ -75,23 +76,21 @@ class AuthenticationController {
|
||||
}
|
||||
|
||||
@PostMapping("/manageUserProfile")
|
||||
@JwtVerify
|
||||
public ResponseEntity<Object> manageUserProfile(@RequestBody ManageUserProfileRequest userProfileRequest) {
|
||||
String username = JwtUtil.extractUsername(userProfileRequest.getToken());
|
||||
if (username != null) {
|
||||
boolean succeeded = userService.updateUserProfile(username, userProfileRequest);
|
||||
if (succeeded) {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
boolean succeeded = userService.updateUserProfile(username, userProfileRequest);
|
||||
if (succeeded) {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@PostMapping("/changePassword")
|
||||
@JwtVerify
|
||||
public ResponseEntity<Object> changePassword(@RequestBody ChangePasswordRequest changePasswordRequest) {
|
||||
if (JwtUtil.isTokenValid(changePasswordRequest.getToken())) {
|
||||
if (userService.changePassword(JwtUtil.extractUsername(changePasswordRequest.getToken()), changePasswordRequest)) {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
if (userService.changePassword(JwtUtil.extractUsername(changePasswordRequest.getToken()), changePasswordRequest)) {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ -2,10 +2,11 @@ package org.cmh.backend.authentication.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.cmh.backend.Utils.JwtRequest;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ChangePasswordRequest extends JwtRequest{
|
||||
public class ChangePasswordRequest extends JwtRequest {
|
||||
private String currentPassword;
|
||||
private String newPassword;
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
package org.cmh.backend.authentication.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class JwtRequest {
|
||||
private String token;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package org.cmh.backend.authentication.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.cmh.backend.Utils.JwtRequest;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
Loading…
Reference in New Issue
Block a user