Skip to content

Commit

Permalink
#5 Refactor : 유저 로그아웃 - res에 userStatus 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhn committed Jan 5, 2023
1 parent a5f4ec6 commit 319dcb2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,8 @@ public ApplicationResponse<UserDeviceTokenRes> addDeviceToken(@ModelAttribute Ad
})
@PostMapping(value = "/log-out")
@ResponseBody
public ApplicationResponse<String> logInApple(@ModelAttribute LogoutReq logoutReq) {
public ApplicationResponse<LogoutRes> logInApple(@ModelAttribute LogoutReq logoutReq) {

userService.logout(logoutReq);

return ApplicationResponse.ok("로그아웃에 성공했습니다.");
return userService.logout(logoutReq);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.yogit.server.user.dto.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class LogoutRes {
String userStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public interface UserService {

ApplicationResponse<UserDeviceTokenRes> addDeviceToken(AddUserDeviceTokenReq addUserDeviceTokenReq);

void logout(LogoutReq logoutReq);
ApplicationResponse<LogoutRes> logout(LogoutReq logoutReq);
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,16 @@ public ApplicationResponse<UserDeviceTokenRes> addDeviceToken(AddUserDeviceToken

@Override
@Transactional
public void logout(LogoutReq logoutReq){
public ApplicationResponse<LogoutRes> logout(LogoutReq logoutReq){

validateRefreshToken(logoutReq.getUserId(), logoutReq.getRefreshToken());

User user = userRepository.findByUserId(logoutReq.getUserId()).orElseThrow(NotFoundUserException::new);
user.changeUserStatus(UserStatus.LOGOUT);

LogoutRes logoutRes = new LogoutRes(UserStatus.LOGOUT.toString());

return ApplicationResponse.ok(logoutRes);
}

}

0 comments on commit 319dcb2

Please sign in to comment.