Skip to content

Commit

Permalink
Merge pull request #134 from Na-o-man/fix/#131/share-group-join-fix
Browse files Browse the repository at this point in the history
[FIX] 이미 존재하는 프로필에 참여 못하게 하는 로직
  • Loading branch information
bflykky authored Aug 23, 2024
2 parents d3a2cc5 + c2d130b commit 6d81152
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public ShareGroup joinShareGroup(Long shareGroupId, Long profileId, Member membe
throw new BusinessException(ShareGroupErrorCode.INVALID_PROFILE_FOR_GROUP);
}

//공유그룹에 해당 profile로 참여한 회원이 이미 있으면
if (profile.getMember() != null) {
throw new BusinessException(ShareGroupErrorCode.MEMBER_ALREADY_EXIST);
}

//해당 멤버(본인)을 선택한 profile에 세팅, 저장
profile.setInfo(member);
profileRepository.save(profile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum ShareGroupErrorCode implements ErrorCode {
INVALID_PROFILE_FOR_GROUP(400, "EG007", "해당 프로필은 이 공유 그룹에 속하지 않습니다."),

UNAUTHORIZED_DELETE(403, "EG008", "공유 그룹을 삭제할 권한이 없습니다."),
ALREADY_JOINED(400, "EG009", "이미 해당 공유 그룹에 참여하였습니다.");
ALREADY_JOINED(400, "EG009", "이미 해당 공유 그룹에 참여하였습니다."),
MEMBER_ALREADY_EXIST(400, "EG010", "이미 해당 프로필로 공유 그룹에 참여한 멤버가 존재합니다.")
;

private final int status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
import java.util.Base64;

public class CookieUtils {
private static final String COOKIE_DOMAIN = ".naoman.site";
// private static final String COOKIE_DOMAIN = ".naoman.site";
private static final String COOKIE_DOMAIN = "localhost";
public static void addCookie(HttpServletResponse response, String name, String value, int maxAge) {
ResponseCookie cookie = ResponseCookie.from(name, value)
.path("/")
.domain(COOKIE_DOMAIN)
.maxAge(maxAge)
.httpOnly(false)
.secure(true)
.sameSite("None")
// .secure(true)
// .sameSite("None")
.build();

response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString());
Expand Down

0 comments on commit 6d81152

Please sign in to comment.