Fix SonarQube Warnings(LDB-11) - #19
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough인증 리다이렉트와 토큰 갱신 처리를 수정했습니다. Day.js 로케일 초기화와 실패 복구를 변경했습니다. 모듈 경로, viewport 설정 및 프로젝트 버전을 업데이트했습니다. Changes런타임 및 모듈 정리
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AuthRoute
participant Timer
participant Navigate
AuthRoute->>Timer: user 변경 감지
Timer->>AuthRoute: 0ms 후 shouldRedirect 갱신
AuthRoute->>Navigate: 미인증 상태에서 replace 리다이렉트
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fix login redirect error
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/common/lib/dayjs.ts`:
- Around line 29-30: Remove the i18n.changeLanguage call from the
languageChanged listener in the dayjs locale setup, leaving the handler
responsible only for updating the Day.js locale. Preserve changeLanguage calls
in explicit invocation paths so the listener does not recursively trigger
duplicate language changes or events.
- Around line 31-33: Update the catch blocks in the dayjs locale initialization
and handler paths to avoid dynamically importing the Korean locale again;
statically load the Korean locale once, then use dayjs.locale('ko') in both
fallback paths so they do not reject when the primary locale load fails.
In `@src/routes/_auth-required/route.tsx`:
- Line 15: Update the route’s rendering and redirect guards around
shouldRedirect to check the current user together with the flag. Do not render
the protected Outlet while user is null or while a redirect is pending, and only
redirect when user remains unauthenticated and shouldRedirect is true; allow an
authenticated user to render the Outlet without being redirected.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: af6e63d6-930d-425b-a2e9-e3ee76db53e9
📒 Files selected for processing (8)
index.htmlpackage.jsonscripts/gen-api.tssrc/common/lib/api.tssrc/common/lib/dayjs.tssrc/features/auth/models/index.tssrc/routes/_auth-required/route.tsxsrc/routes/auth/route.tsx
| function AuthRequiredLayout() { | ||
| const { user } = useAuth(); | ||
| const router = useRouter(); | ||
| const [shouldRedirect, setShouldRedirect] = useState(false); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
지연된 리다이렉트 동안 보호된 Outlet을 렌더링하지 마세요.
useAuth는 토큰이 없을 때 user를 즉시 null로 반환합니다. shouldRedirect의 초기값은 false이므로 첫 렌더에서 보호된 <Outlet />가 반환됩니다. setTimeout(..., 0)이 실행되기 전에 보호된 자식 컴포넌트가 마운트되고 이펙트를 실행할 수 있습니다.
또한 shouldRedirect가 true인 뒤 user가 인증된 객체로 변경되면, 다음 이펙트가 실행되기 전 렌더에서 /auth로 잘못 이동할 수 있습니다. 현재 user와 shouldRedirect를 함께 검사하세요.
수정 예시
- if (user === undefined) return <Loading />;
+ if (user === undefined || (user === null && !shouldRedirect)) return <Loading />;
- if (shouldRedirect) {
+ if (user === null && shouldRedirect) {근거: src/features/auth/viewmodels/use-auth.ts는 토큰 부재를 null, 사용자 조회 중인 상태를 undefined로 구분합니다.
Also applies to: 20-30, 32-35
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/routes/_auth-required/route.tsx` at line 15, Update the route’s rendering
and redirect guards around shouldRedirect to check the current user together
with the flag. Do not render the protected Outlet while user is null or while a
redirect is pending, and only redirect when user remains unauthenticated and
shouldRedirect is true; allow an authenticated user to render the Outlet without
being redirected.
Summary by CodeRabbit
개선 사항
버그 수정