Merge branch 'BE/userinfo' into 'backend'
feat: 유저 정보 변경 See merge request s11-webmobile1-sub2/S11P12A701!142
This commit is contained in:
commit
b9c2a254b3
@ -47,12 +47,17 @@ public class UserController {
|
||||
|
||||
@PutMapping("/updateinfo")
|
||||
public ResponseEntity<String> updateUserInfo(@RequestBody InfoDto infoDto, HttpServletRequest request) {
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
|
||||
userService.changeUserInfo(infoDto, userId);
|
||||
try {
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
|
||||
userService.changeUserInfo(infoDto, userId);
|
||||
return ResponseEntity.ok("Password changed successfully");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body(e.getMessage());
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
// 비밀번호 변경
|
||||
|
@ -72,11 +72,11 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public void changeUserInfo(InfoDto infoDto, Long id) {
|
||||
|
||||
User user = userRepository.findById(id).orElseThrow(IllegalArgumentException::new);
|
||||
User user = userRepository.findById(id).orElse(null);
|
||||
|
||||
|
||||
if (isEmailExist(infoDto.getEmail())) {
|
||||
throw new IllegalArgumentException("이미 사용 중인 이메일입니다.");
|
||||
throw new RuntimeException("이미 사용 중인 이메일입니다.");
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user