Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] fix login #35

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.kakaogroom6.server.global.errors.code.CommonErrorCode;
import com.kakaogroom6.server.global.errors.exception.RestApiException;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.time.format.DateTimeFormatter;
Expand All @@ -25,7 +26,7 @@ public class CommentService {
private final MemberRepository memberRepository;
private final TravelogRepository travelogRepository;

public boolean saveComment(String email, CommentRequestDto request){
public boolean saveComment(@Value("${security.email}")String email, CommentRequestDto request){
MemberEntity member = memberRepository.findByEmail(email)
.orElseThrow(() -> new RestApiException(CommonErrorCode.MEMBER_NOT_FOUND));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.kakaogroom6.server.domain.profile.dto.res.ProfileResponseDto;
import com.kakaogroom6.server.domain.profile.service.ProfileService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -17,7 +18,7 @@ public class ProfileController {
private final ProfileService profileService;

@GetMapping
public ProfileResponseDto getMember(@CookieValue(name = "email", required = true)String email){
public ProfileResponseDto getMember(@Value("${security.email}")String email){
return profileService.getProfile(email);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.kakaogroom6.server.domain.travelog.service.TravelogService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -48,7 +49,7 @@ public ResponseEntity<TravelogsResponseDto> searchTravelogs(
public ResponseEntity<CreateTravelogResponseDTO> createTravelog(
@RequestPart(value = "mainImage",required = false) MultipartFile mainImage,
@RequestPart("travelog") String travelogJson,
@RequestParam("email") String email
@Value("${security.email}") String email
) {

ObjectMapper objectMapper = new ObjectMapper();
Expand All @@ -74,7 +75,7 @@ public ResponseEntity<CreateTravelogResponseDTO> createTravelog(

@PostMapping("/comment")
public ResponseEntity<?> addComment(
@CookieValue(name = "email", required = true)String email,
@Value("${security.email}")String email,
@Valid @RequestBody CommentRequestDto request){
boolean response = commentService.saveComment(email, request);
return ResponseEntity.ok(response);
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cloud:
s3:
bucket: ${S3_BUCKET}
stack:
auto: false
auto: false

security:
email: "[email protected]"
Loading