Skip to content

Commit

Permalink
Merge pull request #285 from bankidz/dev
Browse files Browse the repository at this point in the history
[v1.1.10] 유저 로직 관련 수정 버전
  • Loading branch information
sanbonai06 authored Jan 1, 2023
2 parents c8ae44a + d58e7de commit 1f9a1df
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ceos.bankids.controller.request;

import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
Expand All @@ -18,6 +17,6 @@
public class ExpoRequest {

@ApiModelProperty(example = "ExponentPushToken[asdfasdfasdf]")
@NotNull(message = "expoToken may not be null")
// @NotNull(message = "expoToken may not be null")
private String expoToken;
}
21 changes: 10 additions & 11 deletions src/main/java/com/ceos/bankids/mapper/AppleMapper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ceos.bankids.mapper;

import com.ceos.bankids.constant.ErrorCode;
import com.ceos.bankids.controller.request.AppleRequest;
import com.ceos.bankids.domain.User;
import com.ceos.bankids.dto.oauth.AppleKeyListDTO;
Expand Down Expand Up @@ -31,36 +30,36 @@ public User postAppleLogin(MultiValueMap<String, String> formData) throws BadReq
AppleRequest appleRequest = appleService.getAppleRequest(formData);
AppleKeyListDTO appleKeyListDTO = appleService.getAppleIdentityToken();
AppleSubjectDTO appleSubjectDTO = appleService.verifyIdentityToken(appleRequest,
appleKeyListDTO);
appleKeyListDTO);
AppleTokenDTO appleTokenDTO = appleService.getAppleAccessToken(appleRequest, "login");

Optional<User> registeredUser = userService.findUserByAuthenticationCodeNullable(
appleSubjectDTO.getAuthenticationCode());
appleSubjectDTO.getAuthenticationCode());

User user;
if (registeredUser.isPresent()) {
user = registeredUser.get();

if (user.getExpoToken() != null && user.getExpoToken().contains("ExponentPushToken")) {
throw new BadRequestException(ErrorCode.USER_ALREADY_LOGINED.getErrorCode());
}
// if (user.getExpoToken() != null && user.getExpoToken().contains("ExponentPushToken")) {
// throw new BadRequestException(ErrorCode.USER_ALREADY_LOGINED.getErrorCode());
// }
} else {
user = userService.createNewUser(
appleRequest.getUsername(),
appleSubjectDTO.getAuthenticationCode(),
"apple");
appleRequest.getUsername(),
appleSubjectDTO.getAuthenticationCode(),
"apple");
}

return user;
}

public void postAppleRevoke(MultiValueMap<String, String> formData,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException {
try {
AppleRequest appleRequest = appleService.getAppleRequest(formData);
AppleKeyListDTO appleKeyListDTO = appleService.getAppleIdentityToken();
AppleSubjectDTO appleSubjectDTO = appleService.verifyIdentityToken(appleRequest,
appleKeyListDTO);
appleKeyListDTO);
AppleTokenDTO appleTokenDTO = appleService.getAppleAccessToken(appleRequest, "revoke");
Object appleResponse = appleService.revokeAppleAccount(appleTokenDTO);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public KidChallengeListDTO readKidChallengeListMapper(User authUser, Long kidId,
challenge);
if (challengeListMapperDTO.getChangeStatus()
&& challenge.getChallengeStatus() == ChallengeStatus.ACHIEVED) {
notificationService.challengeAchievedNotification(authUser,
notificationService.challengeAchievedNotification(kidUser,
challenge.getContractUser(), challenge);
kidService.userLevelUp(challenge.getContractUser(),
kidUser);
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/com/ceos/bankids/mapper/KakaoMapper.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.ceos.bankids.mapper;

import com.ceos.bankids.constant.ErrorCode;
import com.ceos.bankids.controller.request.KakaoRequest;
import com.ceos.bankids.domain.User;
import com.ceos.bankids.dto.oauth.KakaoTokenDTO;
import com.ceos.bankids.dto.oauth.KakaoUserDTO;
import com.ceos.bankids.exception.BadRequestException;
import com.ceos.bankids.service.KakaoServiceImpl;
import com.ceos.bankids.service.UserServiceImpl;
import java.util.Optional;
Expand All @@ -29,20 +27,20 @@ public User postKakaoLogin(KakaoRequest kakaoRequest) {
KakaoUserDTO kakaoUserDTO = kakaoService.getKakaoUserCode(kakaoTokenDTO);

Optional<User> registeredUser = userService.findUserByAuthenticationCodeNullable(
kakaoUserDTO.getAuthenticationCode());
kakaoUserDTO.getAuthenticationCode());

User user;
if (registeredUser.isPresent()) {
user = registeredUser.get();

if (user.getExpoToken() != null && user.getExpoToken().contains("ExponentPushToken")) {
throw new BadRequestException(ErrorCode.USER_ALREADY_LOGINED.getErrorCode());
}
// if (user.getExpoToken() != null && user.getExpoToken().contains("ExponentPushToken")) {
// throw new BadRequestException(ErrorCode.USER_ALREADY_LOGINED.getErrorCode());
// }
} else {
user = userService.createNewUser(
kakaoUserDTO.getKakaoAccount().getProfile().getNickname(),
kakaoUserDTO.getAuthenticationCode(),
"kakao");
kakaoUserDTO.getKakaoAccount().getProfile().getNickname(),
kakaoUserDTO.getAuthenticationCode(),
"kakao");
}

return user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ public NotificationListDTO readNotificationList(User user, Long lastId) {
public NotificationDTO updateNotification(User user, Long notificationId) {
Notification notification = notificationRepository.findById(notificationId).orElseThrow(
() -> new BadRequestException(ErrorCode.NOT_EXIST_NOTIFICATION_ERROR.getErrorCode()));
if (notification.getIsRead()) {
throw new BadRequestException(ErrorCode.ALREADY_READ_NOTIFICATION_ERROR.getErrorCode());
}
// if (notification.getIsRead()) {
// throw new BadRequestException(ErrorCode.ALREADY_READ_NOTIFICATION_ERROR.getErrorCode());
// }
if (!Objects.equals(notification.getUser().getId(), user.getId())) {
throw new ForbiddenException(
ErrorCode.NOT_MATCH_NOTIFICATION_USER_ERROR.getErrorCode());
}
notification.setIsRead(true);
notificationRepository.save(notification);
if (!notification.getIsRead()) {
notification.setIsRead(true);
notificationRepository.save(notification);
}
return new NotificationDTO(notification);
}

Expand Down

0 comments on commit 1f9a1df

Please sign in to comment.