Skip to content

Commit

Permalink
Merge pull request #153 from farmingsoon/develop
Browse files Browse the repository at this point in the history
배포를 위한 Main merge
  • Loading branch information
gkfktkrh153 authored Mar 23, 2024
2 parents df95119 + d8a104a commit 2f71cb4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
response.getWriter().write(
objectMapper.writeValueAsString(LoginResponse.of(member))
);
response.sendRedirect("https://farmingsoon.site/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ public Response<Void> rotateToken(HttpServletRequest request, HttpServletRespons
log.info(refreshToken);
return Response.success(HttpStatus.OK, "토큰이 재발급 되었습니다.");
}

@LoginChecking
@GetMapping("/info")
public Response<Void> getUserInfo(){
memberService.getUserInfo();
return Response.success(HttpStatus.OK, "토큰이 재발급 되었습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.api.farmingsoon.common.exception.custom_exception.NotFoundException;
import com.api.farmingsoon.common.security.jwt.JwtProvider;
import com.api.farmingsoon.common.security.jwt.JwtToken;
import com.api.farmingsoon.common.util.AuthenticationUtils;
import com.api.farmingsoon.common.util.CookieUtils;
import com.api.farmingsoon.common.util.JwtUtils;
import com.api.farmingsoon.common.util.Transaction;
Expand All @@ -18,6 +19,7 @@
import com.api.farmingsoon.domain.member.event.TokenRotateEvent;
import com.api.farmingsoon.domain.member.model.Member;
import com.api.farmingsoon.domain.member.repository.MemberRepository;
import com.nimbusds.openid.connect.sdk.UserInfoResponse;
import io.lettuce.core.RedisCommandTimeoutException;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
Expand All @@ -29,6 +31,7 @@
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -150,4 +153,9 @@ public Member getMemberById(Long memberId) {
return memberRepository.findById(memberId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MEMBER));
}

public LoginResponse getUserInfo() {
String userEmail = SecurityContextHolder.getContext().getAuthentication().getName();
Member member = memberRepository.findByEmail(userEmail).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MEMBER));
return LoginResponse.of(member);
}
}

0 comments on commit 2f71cb4

Please sign in to comment.