-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat: 관리자 인증 및 인가 기능 구현 #213
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! 세션 방식으로 로그인은 처음 구경해보는데 HttpSession 클래스가 따로 있었군요... 간단한 코멘트 몇 개 남겼습니다!
public class MemberAdminController { | ||
|
||
private final MemberRepository memberRepository; | ||
private final TokenService tokenService; | ||
private final DummyProperties dummyProperties; | ||
|
||
private final String adminEmail = "[email protected]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이메일이랑 비밀번호는 코드 상에 드러나면 안되니까 이메일 및 비밀번호는 수정해서 dev-properties에 담아주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 처리해두었습니다~!
HttpSession session) { | ||
if (adminEmail.equals(email) && adminPassword.equals(password)) { | ||
session.setAttribute("email", email); | ||
session.setAttribute("role", "ADMIN"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 timeout도 추가해주면 좋을 것 같습니다!
session.setMaxInactiveInterval(1800);
요렇게 추가하면 될거에요. 위의 코드안의 숫자는 초단위라 저렇게 작성하면 만료시간이 30분임을 의미합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추가로 로그인할 때 sessionId가 url에 남던데,
server.servlet.session.tracking-modes = cookie
을 properties에 추가하면 url에 남지 않습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오 좋은 정보 감사해요ㅎㅎ 적용해두었어요
public String showDummyLoginPage(Model model) { | ||
List<Member> dummyMembers = memberRepository.findAllByEmailIn(dummyEmails); | ||
model.addAttribute("members", dummyMembers); | ||
return "dummy/login"; | ||
} | ||
|
||
@PostMapping | ||
@GetMapping("/admin/login") | ||
public String showAdminLoginPage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금은 한 번 로그인한 후 "/admin/login"으로 이동하면 다시 로그인을 해야 되던데,
if (isAdmin(session)) { return "redirect:/admin/point/charge"; }
해당 로직을 추가하면 방지할 수 있을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 처리해두었습니다!
감사합니다:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! 👍
꼭 필요한 부분 관련한 코멘트 남겼습니다
혹시 문제 생기면 카톡으로 말씀해주세요~
private final String adminEmail = "[email protected]"; | ||
private final String adminPassword = "1234"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 이미 깃허브 커밋에 push 된상태라 추후에 삭제한다고해도 이미 이전커밋기록보면 뜰것 같아요.
최소 비빌번호는 변경해주시고
dev.properties에 받을 때 @value로 받으면 깃액션 테스트코드에서 설정할것들이 늘어나는데 그런식으로 하지말고 /common/properties에 AdminProperties하나 추가해서
@ConfigurationProperties(prefix = "admin")
public record AdminProperties(
String adminEmail,
String adminPassword
) {
}
이렇게 추가해주시고
SinittoApplication 클래스에서
@EnableConfigurationProperties({KakaoProperties.class, DummyProperties.class, AdminProperties.class})
이렇게 변경해주세요
dev.properties 파일에
admin.adminEmail={어드민이메일}
admin.adminPassword={어드민비번}
이런식으로 추가해주시면 됩니다
수정) dev파일에 띄어쓰기 x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변경 후 dev속성파일은 카톡방 등에 공유해주세요~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 모두 반영해두었습니다~!
감사해요 :>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헤더추가하여 우측상단 버튼통해서 페이지 전환할 수 있는거 좋네요😃 고생하셨습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
실행해보니 잘 되는 것 같네요 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정하신 부분 확인했습니다! 고생했어요~
#️⃣ 연관된 이슈
📝 작업 내용
💬 리뷰 요구사항(선택)
⏰ 현재 버그
✏ Git Close