Skip to content

Commit

Permalink
Refactor: 로그인 방식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yso8296 committed Nov 15, 2024
1 parent f62743c commit 866bae3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ public class MemberController {

private final MemberService memberService;

@GetMapping("/login")
/*@GetMapping("/login")
public ResponseEntity<Void> login() {
String loginUrl = memberService.getCodeUrl();
return ResponseEntity.status(HttpStatus.SEE_OTHER)
.header("location", loginUrl)
.build();
}
}*/

@GetMapping("/callback")
public ResponseEntity<MemberResponse.Login> registerMember(
@RequestParam("code") String code
@RequestParam("token") String token
) {
MemberModel.Login memberInfo = memberService.register(code);
MemberModel.Login memberInfo = memberService.register(token);


return ResponseEntity.status(HttpStatus.CREATED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public String getCodeUrl() {
}

@Transactional
public MemberModel.Login register(String code) {
public MemberModel.Login register(String token) {
// 토큰 발급
TokenInfoResponse tokenResponse = memberApiCaller.getAccessToken(code);
String accessToken = tokenResponse.accessToken();
String kakaoToken = token;

// 카카오 사용자 정보 요청
UserInfoResponse userInfoResponse = memberApiCaller.extractUserInfo(accessToken);
UserInfoResponse userInfoResponse = memberApiCaller.extractUserInfo(kakaoToken);
KakaoAccount kakaoAccount = userInfoResponse.kakaoAccount();

// Users 저장 및 중복 체크
Expand All @@ -41,10 +41,10 @@ public MemberModel.Login register(String code) {
return newMember;
});

String token = jwtProvider.createToken(member.getId(), member.getEmail());
System.out.println(token);
String accessToken = jwtProvider.createToken(member.getId(), member.getEmail());
System.out.println(accessToken);

return MemberModel.Login.from(token);
return MemberModel.Login.from(accessToken);
}

public MemberModel.Info getMemberInfo(Long memberId) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/hackathon/nullnullteam/ocr/OcrService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public List<String> extractTextFromImage(MultipartFile file) {
ResponseEntity<String> response = restTemplate.exchange(ocrUrl, HttpMethod.POST, requestEntity, String.class);
JSONObject object = new JSONObject(response.getBody());
List<String> text = extractInferText(object);

StringBuilder sb = new StringBuilder();
for (String t : text) {
sb.append(t + " ");
}
System.out.println(sb.toString());
return text;
}

Expand Down

0 comments on commit 866bae3

Please sign in to comment.