Skip to content

[FEAT] 로비 로그인 구현 및 회원가입 버튼 수정#98

Merged
ochanhyeok merged 1 commit intodevfrom
FEAT-game-ui-개선
Dec 23, 2025

Hidden character warning

The head ref may contain hidden characters: "FEAT-game-ui-\uac1c\uc120"
Merged

[FEAT] 로비 로그인 구현 및 회원가입 버튼 수정#98
ochanhyeok merged 1 commit intodevfrom
FEAT-game-ui-개선

Conversation

@ochanhyeok
Copy link
Collaborator

@ochanhyeok ochanhyeok commented Dec 23, 2025

📌 작업 내용

  • 이번 PR에서 수행한 작업을 정리해 주세요.

🔗 관련 이슈

  • closes #

👀 리뷰 시 참고사항

  • 리뷰어가 중점적으로 보면 좋을 부분을 작성해 주세요.
  • 고민한 지점이나 피드백 받고 싶은 부분이 있다면 함께 남겨주세요.

💭 느낀 점

  • 작업하면서 느낀 점이나 공유하고 싶은 내용을 자유롭게 작성해 주세요.

💻 스크린샷 (선택)

  • 필요한 경우 첨부해 주세요.

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능
    • 로그인 폼에 이메일 및 비밀번호 검증 기능 추가
    • 로그인 성공/실패 시 사용자 피드백 메시지 표시
    • Enter 키를 통한 로그인 제출 기능 지원
    • 애플리케이션 시작 시 로비 페이지로 자동 이동

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

로그인 폼에 DOM 요소 ID를 추가하고, 신규 index.jsp 엔트리 포인트를 생성하여 /lobby로 리다이렉트하며, JavaScript 기반 로그인 흐름(폼 검증 및 /noamlLogin 엔드포인트 POST)을 구현합니다.

Changes

Cohort / File(s) Summary
로그인 폼 UI 업데이트
src/main/webapp/WEB-INF/views/lobby.jsp
이메일 입력(login-email), 비밀번호 입력(login-password), 로그인 버튼(btn-login)에 식별 가능한 ID 추가. 회원가입 링크를 /signup2로 업데이트하여 JavaScript 상호작용 및 네비게이션 활성화.
로그인 비즈니스 로직
src/main/webapp/static/lobby/lobby.js
로그인 폼 DOM 바인딩 및 폼 검증 추가(이메일/비밀번호 필수 입력). /noamlLogin 엔드포인트로 POST 요청 수행. 응답 처리: 성공 시(accessToken 포함) 성공 알림 및 페이지 새로고침, 실패 시 오류 메시지 표시. Enter 키로 비밀번호 필드에서 제출 가능.
애플리케이션 엔트리 포인트
src/main/webapp/index.jsp
신규 JSP 파일로 HTML 콘텐츠 타입(UTF-8) 설정 후 /lobby로 자동 리다이렉트.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

FEAT

Suggested reviewers

  • hjh79gw
  • gaeunnlee

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 로비 로그인 구현과 회원가입 버튼 수정이라는 주요 변경사항을 명확하게 요약하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch FEAT-game-ui-개선

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator

@hjh79gw hjh79gw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/main/webapp/static/lobby/lobby.js (1)

131-154: 로딩 상태 및 에러 처리를 개선할 수 있습니다.

현재 구현은 다음과 같은 개선이 가능합니다:

  • 로그인 중 버튼을 비활성화하여 중복 요청 방지
  • HTTP 상태 코드별 구체적인 에러 메시지 제공
  • 네트워크 에러와 서버 에러 구분
🔎 개선된 에러 처리 및 로딩 상태
     btnLogin.addEventListener("click", async () => {
       const email = emailInput.value.trim();
       const password = passwordInput.value.trim();
 
       if (!email || !password) {
         alert("이메일과 비밀번호를 입력해주세요.");
         return;
       }
+
+      // 로딩 상태 시작
+      btnLogin.disabled = true;
+      const originalText = btnLogin.textContent;
+      btnLogin.textContent = "로그인 중...";
 
       try {
         const response = await fetch(CTX + "/noamlLogin", {
           method: "POST",
           headers: { "Content-Type": "application/json" },
           body: JSON.stringify({ email, password })
         });
 
         const data = await response.json();
 
         if (response.ok && data.accessToken) {
           alert("로그인 성공!");
           location.reload();
         } else {
-          alert(data.message || "로그인 실패");
+          // 상태 코드별 메시지 분기
+          if (response.status === 401) {
+            alert(data.message || "이메일 또는 비밀번호가 올바르지 않습니다.");
+          } else if (response.status >= 500) {
+            alert("서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
+          } else {
+            alert(data.message || "로그인 실패");
+          }
         }
       } catch (error) {
         console.error("로그인 오류:", error);
-        alert("로그인 중 오류가 발생했습니다.");
+        alert("네트워크 오류가 발생했습니다. 인터넷 연결을 확인해주세요.");
+      } finally {
+        // 로딩 상태 종료
+        btnLogin.disabled = false;
+        btnLogin.textContent = originalText;
       }
     });
src/main/webapp/index.jsp (1)

2-5: web.xml의 welcome-file 설정 사용을 고려해보세요.

JSP 스크립트릿으로 리다이렉트하는 대신, web.xml에서 welcome-file 설정을 사용하는 것이 더 표준적인 접근 방식입니다.

🔎 web.xml 설정 예시

src/main/webapp/WEB-INF/web.xml에 다음 설정 추가:

<welcome-file-list>
    <welcome-file>lobby</welcome-file>
</welcome-file-list>

그리고 컨트롤러에서 루트 경로를 처리:

@GetMapping("/")
public String redirectToLobby() {
    return "redirect:/lobby";
}

이 방식이 JSP 스크립트릿보다 유지보수가 용이합니다.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4744970 and 95046b3.

📒 Files selected for processing (3)
  • src/main/webapp/WEB-INF/views/lobby.jsp
  • src/main/webapp/index.jsp
  • src/main/webapp/static/lobby/lobby.js
🔇 Additional comments (6)
src/main/webapp/static/lobby/lobby.js (3)

157-163: Enter 키 로그인 기능이 잘 구현되었습니다.

비밀번호 입력 필드에서 Enter 키로 로그인할 수 있어 사용자 경험이 향상됩니다.


137-137: 엔드포인트 URL의 오타는 아닙니다.

/noamlLogin은 백엔드 컨트롤러(JwtLoginController)에 @WebServlet("/noamlLogin")으로 실제 정의되어 있으므로, 프론트엔드의 호출이 올바릅니다. 다만 보안 필터(JwtLoginFilter)에서는 /normalLogin을 제외 대상으로 설정하고 있어 설정 불일치 문제가 있습니다. 필터가 정확하게 로그인 엔드포인트를 인증 검증에서 제외하려면, 필터 설정을 /noamlLogin으로 수정해야 합니다.

Likely an incorrect or invalid review comment.


145-147: accessToken을 저장할 필요가 없습니다 - 세션 기반 인증을 사용 중입니다.

이 애플리케이션은 HTTP 세션 기반 인증을 사용하므로, 토큰을 클라이언트에 저장할 필요가 없습니다. 로그인 후 location.reload()를 호출해도 JSESSIONID 쿠키로 인해 세션이 유지되며, 백엔드는 session.getAttribute("accessToken")로 토큰을 검증합니다.

현재 설계의 문제점: 응답 본문에 accessToken을 포함시키는 것은 세션 기반 인증에서는 불필요하며, JWT 클라이언트 저장 방식과 세션 방식이 혼재되어 있어 혼동을 유발합니다. 세션 기반이라면 응답 본문에서 토큰을 제거하는 것이 명확합니다.

Likely an incorrect or invalid review comment.

src/main/webapp/WEB-INF/views/lobby.jsp (2)

92-92: 로그인 폼 요소에 ID가 잘 추가되었습니다.

JavaScript에서 참조할 수 있도록 login-email, login-password, btn-login ID가 적절히 추가되어 lobby.js의 로그인 로직과 올바르게 연결됩니다.

Also applies to: 97-97, 100-100


111-111: /signup2 엔드포인트는 백엔드에 올바르게 구현되어 있습니다. SignupPageServlet/signup2로 매핑되어 있으며, 가입 폼 화면을 표시하고 실제 가입 처리는 JwtSignupController/nomalSignup으로 처리합니다.

Likely an incorrect or invalid review comment.

src/main/webapp/index.jsp (1)

1-5: /lobby 엔드포인트가 정상적으로 구현되어 있습니다.

ViewRoomListController@WebServlet("/lobby")로 매핑되어 로비 페이지를 제공하고 있으며, JWT 필터에서 인증 없이 접근 가능하도록 설정되어 있습니다.

<label>비밀번호</label>
<input type="password" placeholder="비밀번호" />
<input id="login-password" type="password" placeholder="비밀번호" />
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

HTML 속성에 구문 오류가 있습니다.

action 속성 값에 중복된 따옴표가 있습니다: action="${CTX}/room/enter"" → 따옴표가 두 개 연속으로 나타납니다.

🔎 구문 오류 수정
-          <form class="enter-room-form" action="${CTX}/room/enter"" method="post">
+          <form class="enter-room-form" action="${CTX}/room/enter" method="post">

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/main/webapp/WEB-INF/views/lobby.jsp around line 98, the HTML has a syntax
error: the action attribute contains a duplicated double-quote
(`action="${CTX}/room/enter""`). Remove the extra quote so the attribute is
properly quoted (e.g., action="${CTX}/room/enter"), and scan the surrounding tag
to ensure there are no other stray or mismatched quotes in the same element.

Copy link
Collaborator

@kkhhmm3103 kkhhmm3103 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고

@ochanhyeok ochanhyeok merged commit 58d8ae0 into dev Dec 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants