Skip to content
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

πŸ”€ 역할에 λ”°λ₯Έ url 처리 진행 #77

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

Ethen1264
Copy link
Contributor

@Ethen1264 Ethen1264 commented Jan 15, 2025

πŸ’‘ λ°°κ²½ 및 κ°œμš”

역할에 λ”°λ₯Έ url 처리 진행

πŸ“ƒ μž‘μ—…λ‚΄μš©

역할에 따라 νŠΉμ • νŽ˜μ΄μ§€λ‘œ 접속이 λ˜μ§€ μ•Šλ„λ‘ μ μš©ν–ˆλ‹€.

🎸 기타

MANAGE_RESTRICTED_PATHS와 USER_RESTRICTED_PATHS 2개둜 λ‚˜λˆ„μ–΄ μ •κ·œμ‹μ„ μ μš©ν•˜μ˜€λ‹€.
μ΄λ‘œμΈν•΄ ν•΄λ‹Ή μ •κ·œμ‹μ΄ μ˜³μ€μ§€ μΆ©λΆ„ν•œ ν…ŒμŠ€νŠΈκ°€ ν•„μš”ν•΄λ³΄μΈλ‹€.

Summary by CodeRabbit

  • μƒˆλ‘œμš΄ κΈ°λŠ₯

    • κ΄€λ¦¬μž 계정 μ‚­μ œ κΈ°λŠ₯ μΆ”κ°€
    • λ‘œκ·Έμ•„μ›ƒ 및 계정 μ‚­μ œλ₯Ό μœ„ν•œ μƒˆλ‘œμš΄ μ‚¬μš©μž μΈν„°νŽ˜μ΄μŠ€ κ°œμ„ 
  • 버그 μˆ˜μ •

    • μ ‘κ·Ό 토큰 관리 및 경둜 μ œν•œ 둜직 κ°•ν™”
  • λ³΄μ•ˆ κ°œμ„ 

    • μ‚¬μš©μž μ—­ν•  및 경둜 μ ‘κ·Ό μ œμ–΄ λ©”μ»€λ‹ˆμ¦˜ μ—…λ°μ΄νŠΈ
    • 토큰 기반 인증 ν”„λ‘œμ„ΈμŠ€ κ°œμ„ 

@Ethen1264 Ethen1264 added 1️⃣ Priority: High μš°μ„ μˆœμœ„ - 상 ✨ Feature μ‹ κ·œ κΈ°λŠ₯ labels Jan 15, 2025
@Ethen1264 Ethen1264 self-assigned this Jan 15, 2025
Copy link

coderabbitai bot commented Jan 15, 2025

μ›Œν¬μŠ€λ£¨

이 ν’€ λ¦¬ν€˜μŠ€νŠΈλŠ” κ΄€λ¦¬μž 계정 μ‚­μ œ κΈ°λŠ₯을 μΆ”κ°€ν•˜κ³  λ―Έλ“€μ›¨μ–΄μ˜ 경둜 μ œν•œ λ‘œμ§μ„ κ°œμ„ ν•©λ‹ˆλ‹€. μƒˆλ‘œμš΄ API μ—”λ“œν¬μΈνŠΈμ™€ ν”„λ‘ νŠΈμ—”λ“œ μ»΄ν¬λ„ŒνŠΈλ₯Ό 톡해 κ΄€λ¦¬μžκ°€ μžμ‹ μ˜ 계정을 μ‚­μ œν•  수 있게 λ˜μ—ˆμœΌλ©°, λ―Έλ“€μ›¨μ–΄λŠ” μ‚¬μš©μž μ—­ν• κ³Ό 경둜 접근에 λŒ€ν•œ 더 μ„Έλ°€ν•œ μ œμ–΄λ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.

λ³€κ²½ 사항

파일 λ³€κ²½ μš”μ•½
src/app/api/admin/route.ts κ΄€λ¦¬μž 계정 μ‚­μ œλ₯Ό μœ„ν•œ DELETE λ©”μ„œλ“œ μΆ”κ°€
src/entities/admin/api/deleteUserAccount.ts μ‚¬μš©μž 계정 μ‚­μ œ API ν•¨μˆ˜ 생성
src/entities/admin/model/useDeleteUserAccount.ts 계정 μ‚­μ œλ₯Ό μœ„ν•œ μ»€μŠ€ν…€ ν›… κ΅¬ν˜„
src/entities/admin/ui/AdminProfile/index.tsx 계정 μ‚­μ œ 및 λ‘œκ·Έμ•„μ›ƒ UI κΈ°λŠ₯ κ°œμ„ 
src/middleware.ts 경둜 μ œν•œ 및 μ—­ν•  관리 둜직 λ¦¬νŒ©ν† λ§

κ°€λŠ₯ν•œ κ΄€λ ¨ PR

μ œμ•ˆλœ λ ˆμ΄λΈ”

♻️ Refactor

μ œμ•ˆλœ 리뷰어

  • happytaeyoon

μ‹œ(θ©©)

🐰 κ΄€λ¦¬μžμ˜ κΈΈ, μ‚­μ œμ˜ λ¬Έ
μ½”λ“œλŠ” 흐λ₯΄κ³  κΈ°λŠ₯은 좀을
미듀웨어 문지기, 경둜λ₯Ό μ§€ν‚€λ‹ˆ
λ³΄μ•ˆμ˜ 토끼, μ•ˆμ „ν•˜κ²Œ λ›°μ–΄κ°€λ„€! πŸš€

Finishing Touches

  • πŸ“ Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 5

🧹 Nitpick comments (8)
src/middleware.ts (3)

44-46: 미인증 μ‚¬μš©μžμ— λŒ€ν•œ λ¦¬λ””λ ‰μ…˜ 둜직 κ²€ν† 

미인증 μ‚¬μš©μžκ°€ USER_RESTRICTED_PATHS에 ν•΄λ‹Ήν•˜λŠ” κ²½λ‘œμ— μ ‘κ·Όν•  λ•Œ 루트둜 λ¦¬λ””λ ‰μ…˜ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ μ‚¬μš©μž κ²½ν—˜μ„ ν–₯μƒμ‹œν‚€κΈ° μœ„ν•΄ 둜그인 νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜ν•˜λŠ” 것이 더 μ μ ˆν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜μ—¬ 둜그인 νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜ν•  것을 μ œμ•ˆν•©λ‹ˆλ‹€:

if (!accessToken && isPathMatch(pathname, USER_RESTRICTED_PATHS)) {
-   return NextResponse.redirect(new URL('/', request.url));
+   return NextResponse.redirect(new URL('/signIn', request.url));
}

48-50: 인증된 μ‚¬μš©μžμ— λŒ€ν•œ μ ‘κ·Ό μ œν•œ 둜직 κ²€ν† 

이미 인증된 μ‚¬μš©μžκ°€ MANAGE_RESTRICTED_PATHS에 ν•΄λ‹Ήν•˜λŠ” κ²½λ‘œμ— μ ‘κ·Όν•  λ•Œ 루트둜 λ¦¬λ””λ ‰μ…˜ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ 이 κ²½μš°μ—λ„ μ‚¬μš©μž κ²½ν—˜μ„ κ³ λ €ν•˜μ—¬ νŠΉμ • νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜ν•˜κ±°λ‚˜ 접근을 ν—ˆμš©ν•˜λŠ” 것이 쒋을 수 μžˆμŠ΅λ‹ˆλ‹€.

인증된 μ‚¬μš©μžκ°€ νšŒμ›κ°€μž…μ΄λ‚˜ 둜그인 νŽ˜μ΄μ§€μ— μ ‘κ·Όν•  ν•„μš”κ°€ μ—†λ‹€λ©΄, ν•΄λ‹Ή κ²½λ‘œμ— μ ‘κ·Όν•  경우 λŒ€μ‹œλ³΄λ“œλ‚˜ ν”„λ‘œν•„ νŽ˜μ΄μ§€λ‘œ λ¦¬λ””λ ‰μ…˜ν•˜λŠ” 것을 κ³ λ €ν•΄λ³΄μ„Έμš”.

if (accessToken && isPathMatch(pathname, MANAGE_RESTRICTED_PATHS)) {
-   return NextResponse.redirect(new URL('/', request.url));
+   return NextResponse.redirect(new URL('/dashboard', request.url));
}

56-70: matcher μ„€μ •μ˜ μ„±λŠ₯ 및 μœ μ§€λ³΄μˆ˜μ„± κ°œμ„ 

ν˜„μž¬ matcher 배열에 λ§Žμ€ κ²½λ‘œκ°€ ν•˜λ“œμ½”λ”©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” μœ μ§€λ³΄μˆ˜μ— 어렀움을 쀄 수 있으며, λˆ„λ½λœ κ²½λ‘œλ‚˜ μ˜€νƒ€λ‘œ μΈν•œ 버그가 λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μ •κ·œμ‹μ΄λ‚˜ νŒ¨ν„΄μ„ ν™œμš©ν•˜μ—¬ matcherλ₯Ό κ°„κ²°ν•˜κ²Œ ν‘œν˜„ν•  것을 μ œμ•ˆν•©λ‹ˆλ‹€:

export const config = {
  matcher: [
-   '/api/role',
-   '/signIn',
-   '/signUp',
-   '/admin',
-   '/create-exhibition',
-   '/expo-manage/:path*',
-   '/name-tag/:path*',
-   '/sms/:path*/STANDARD',
-   '/sms/:path*/TRAINEE',
-   '/program/:path*',
-   '/program/detail/:path*',
-   '/application/:path*/STANDARD',
-   '/application/:path*/TRAINEE',
+   '/((api/role)|(signIn)|(signUp)|(admin)|(create-exhibition)|(expo-manage.*)|(name-tag.*)|(sms.*)|(program.*)|(application.*))',
  ],
};
src/entities/admin/model/useDeleteUserAccount.ts (2)

10-10: λΆˆν•„μš”ν•œ ν™”μ‚΄ν‘œ ν•¨μˆ˜ κ°„μ†Œν™”

mutationFnμ—μ„œ λ‹¨μˆœνžˆ λ‹€λ₯Έ ν•¨μˆ˜λ₯Ό ν˜ΈμΆœν•˜κ³  μžˆμœΌλ―€λ‘œ, ν™”μ‚΄ν‘œ ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•˜μ§€ μ•Šκ³  λ°”λ‘œ ν•¨μˆ˜λͺ…을 전달할 수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μ½”λ“œλ₯Ό κ°„μ†Œν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€:

return useMutation({
-   mutationFn: () => deleteUserAccount(),
+   mutationFn: deleteUserAccount,

16-17: μ—λŸ¬ λ©”μ‹œμ§€ κ°œμ„ 

μ—λŸ¬ λ°œμƒ μ‹œ μ‚¬μš©μžμ—κ²Œ μ œκ³΅λ˜λŠ” λ©”μ‹œμ§€λ₯Ό ꡬ체적으둜 μž‘μ„±ν•˜μ—¬ μ‚¬μš©μž κ²½ν—˜μ„ ν–₯μƒμ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€. μ—λŸ¬ μ›μΈμ΄λ‚˜ μΆ”κ°€ μ‘°μΉ˜μ— λŒ€ν•œ μ•ˆλ‚΄λ₯Ό ν¬ν•¨ν•˜λ©΄ μ’‹μŠ΅λ‹ˆλ‹€.

예λ₯Ό λ“€μ–΄:

onError: () => {
-   toast.error('μœ μ € νƒˆν‡΄λ₯Ό μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.');
+   toast.error('νƒˆν‡΄ κ³Όμ •μ—μ„œ λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. μž μ‹œ ν›„ λ‹€μ‹œ μ‹œλ„ν•΄μ£Όμ„Έμš”.');
},
src/app/api/admin/route.ts (2)

39-49: λ³΄μ•ˆ κ°•ν™”λ₯Ό μœ„ν•œ μ œμ•ˆμ‚¬ν•­μ΄ μžˆμŠ΅λ‹ˆλ‹€.

  1. refreshToken의 μœ νš¨μ„±λ„ κ²€μ¦ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.
  2. λ―Όκ°ν•œ μž‘μ—…μ΄λ―€λ‘œ 둜그λ₯Ό μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.
  3. 성곡 응닡 μ‹œ 더 μžμ„Έν•œ λ©”μ‹œμ§€λ₯Ό ν¬ν•¨ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

  try {
+   const refreshToken = cookieStore.get('refreshToken')?.value;
+   if (!refreshToken) {
+     return NextResponse.json(
+       { error: '인증이 ν•„μš”ν•©λ‹ˆλ‹€' },
+       { status: 401 }
+     );
+   }
+   console.log('κ΄€λ¦¬μž 계정 μ‚­μ œ μ‹œλ„:', new Date().toISOString());
    await apiClient.delete('/admin', {
      headers: {
        Authorization: `Bearer ${accessToken}`,
      },
    });
+   console.log('κ΄€λ¦¬μž 계정 μ‚­μ œ 성곡');
    const response = NextResponse.json({ 
-     success: true 
+     success: true,
+     message: 'κ΄€λ¦¬μž 계정이 μ„±κ³΅μ μœΌλ‘œ μ‚­μ œλ˜μ—ˆμŠ΅λ‹ˆλ‹€'
    });

32-37: μ—λŸ¬ λ©”μ‹œμ§€λ₯Ό ν•œκΈ€λ‘œ λ³€κ²½ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

ν˜„μž¬ μ—λŸ¬ λ©”μ‹œμ§€κ°€ μ˜μ–΄λ‘œ λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. 일관성을 μœ„ν•΄ ν•œκΈ€λ‘œ λ³€κ²½ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

  if (!accessToken) {
    return NextResponse.json(
-     { error: 'Access token not found' },
+     { error: 'μ•‘μ„ΈμŠ€ 토큰을 찾을 수 μ—†μŠ΅λ‹ˆλ‹€' },
      { status: 401 },
    );
  }
src/entities/admin/ui/AdminProfile/index.tsx (1)

15-20: μƒνƒœ 관리 λ‘œμ§μ„ λΆ„λ¦¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

ν† κΈ€ μƒνƒœ 관리 λ‘œμ§μ„ λ³„λ„μ˜ μ»€μŠ€ν…€ ν›…μœΌλ‘œ λΆ„λ¦¬ν•˜λ©΄ μž¬μ‚¬μš©μ„±κ³Ό ν…ŒμŠ€νŠΈ μš©μ΄μ„±μ΄ ν–₯μƒλ©λ‹ˆλ‹€.

+ const useToggle = (initialState = false) => {
+   const [state, setState] = useState(initialState);
+   const toggle = useCallback(() => setState(prev => !prev), []);
+   return [state, toggle] as const;
+ };

const AdminProfile = () => {
  const { mutate: logout } = useLogout();
  const { mutate: deleteAccount } = useDeleteUserAccount();
- const [isToggleLogout, setIsToggleLogout] = useState(false);
+ const [isToggleLogout, toggleLogout] = useToggle(false);

- const handleLogoutClick = () => {
-   setIsToggleLogout((prev) => !prev);
- };
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 8396a3d and b80a881.

πŸ“’ Files selected for processing (5)
  • src/app/api/admin/route.ts (1 hunks)
  • src/entities/admin/api/deleteUserAccount.ts (1 hunks)
  • src/entities/admin/model/useDeleteUserAccount.ts (1 hunks)
  • src/entities/admin/ui/AdminProfile/index.tsx (2 hunks)
  • src/middleware.ts (2 hunks)
πŸ”‡ Additional comments (2)
src/middleware.ts (2)

10-17: μ •κ·œμ‹ νŒ¨ν„΄μ˜ μ •ν™•μ„± 확인 ν•„μš”

USER_RESTRICTED_PATHS 배열에 μ •μ˜λœ μ •κ·œμ‹ νŒ¨ν„΄λ“€μ΄ μ˜λ„ν•œ URL듀을 μ •ν™•νžˆ λ§€μΉ­ν•˜λŠ”μ§€ 확인해야 ν•©λ‹ˆλ‹€. 특히 /program κ΄€λ ¨ κ²½λ‘œλ“€μ˜ νŒ¨ν„΄μ΄ λͺ¨λ“  경우λ₯Ό ν¬κ΄„ν•˜λŠ”μ§€ κ²€ν† κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒ 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ—¬ νŒ¨ν„΄ 맀칭을 κ²€μ¦ν•˜μ„Έμš”:

βœ… Verification successful

μ •κ·œμ‹ νŒ¨ν„΄μ΄ μ •ν™•νžˆ κ΅¬ν˜„λ˜μ–΄ μžˆμŒμ„ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€

μ½”λ“œλ² μ΄μŠ€ 뢄석 κ²°κ³Ό, USER_RESTRICTED_PATHS의 λͺ¨λ“  μ •κ·œμ‹ νŒ¨ν„΄μ΄ μ‹€μ œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ—μ„œ μ‚¬μš©λ˜λŠ” λΌμš°νŠΈμ™€ μ •ν™•νžˆ μΌμΉ˜ν•˜λ©°, 각 νŒ¨ν„΄μ΄ μ˜λ„ν•œ URL ꡬ쑰λ₯Ό μ˜¬λ°”λ₯΄κ²Œ λ§€μΉ­ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 특히 /program κ΄€λ ¨ νŒ¨ν„΄λ„ λͺ¨λ“  ν•˜μœ„ 경둜λ₯Ό μ •ν™•ν•˜κ²Œ ν¬ν•¨ν•˜λ„λ‘ κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# μ„€λͺ…: USER_RESTRICTED_PATHS의 μ •κ·œμ‹ νŒ¨ν„΄μ΄ μ˜λ„ν•œ κ²½λ‘œμ™€ λ§€μΉ­λ˜λŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€.

# ν…ŒμŠ€νŠΈ: 각 νŒ¨ν„΄μ— λŒ€ν•΄ λ§€μΉ­λ˜λŠ” 경둜λ₯Ό 좜λ ₯ν•©λ‹ˆλ‹€.
for pattern in '^/admin$' '^/create-exhibition$' '^/expo-manage/.+$' '^/name-tag/.+$' '^/sms/.+/(STANDARD|TRAINEE)$' '^/program(/.*)?$'; do
  echo "νŒ¨ν„΄: $pattern"
  rg --files | grep -E "$pattern"
done

Length of output: 1406


Script:

#!/bin/bash
# Find where USER_RESTRICTED_PATHS is used
echo "=== USER_RESTRICTED_PATHS Usage ==="
rg "USER_RESTRICTED_PATHS" -B 2 -A 2

# Look for route definitions and tests
echo -e "\n=== Route Definitions and Tests ==="
rg "(router\.|app\.|routes?\.|test)" "src/" -g "*.{ts,tsx,js,jsx}" -A 2

# Look for test files that might contain these paths
echo -e "\n=== Path Tests ==="
rg "(admin|create-exhibition|expo-manage|name-tag|sms|program)" "src/" -g "*test*" -A 2

Length of output: 5541


4-8: μ •κ·œμ‹ νŒ¨ν„΄μ˜ μ •ν™•μ„± 확인 ν•„μš”

MANAGE_RESTRICTED_PATHS 배열에 μ •μ˜λœ μ •κ·œμ‹ νŒ¨ν„΄λ“€μ΄ μ˜λ„ν•œ URL듀을 μ •ν™•νžˆ λ§€μΉ­ν•˜λŠ”μ§€ 확인해야 ν•©λ‹ˆλ‹€. 특히 /application/... 경둜의 νŒ¨ν„΄μ΄ μ˜¬λ°”λ₯΄κ²Œ μž‘μ„±λ˜μ—ˆλŠ”μ§€ κ²€ν† κ°€ ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒ 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ—¬ νŒ¨ν„΄ 맀칭을 κ²€μ¦ν•˜μ„Έμš”:

βœ… Verification successful

μ •κ·œμ‹ νŒ¨ν„΄μ΄ μ˜¬λ°”λ₯΄κ²Œ κ΅¬ν˜„λ˜μ–΄ μžˆμŒμ„ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€

middleware.ts의 μ •κ·œμ‹ νŒ¨ν„΄λ“€μ΄ λ‹€μŒκ³Ό 같이 μ •ν™•ν•˜κ²Œ κ΅¬ν˜„λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€:

  • /signIn, /signUp κ²½λ‘œμ— λŒ€ν•œ μ •ν™•ν•œ 맀칭
  • /application/[...]/STANDARD λ˜λŠ” /application/[...]/TRAINEE ν˜•μ‹μ˜ 동적 경둜 맀칭

이 νŒ¨ν„΄λ“€μ€ λ―Έλ“€μ›¨μ–΄μ—μ„œ μ μ ˆν•˜κ²Œ μ‚¬μš©λ˜μ–΄ 인증된 μ‚¬μš©μžμ˜ 접근을 μ œμ–΄ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# μ„€λͺ…: MANAGE_RESTRICTED_PATHS의 μ •κ·œμ‹ νŒ¨ν„΄μ΄ μ˜λ„ν•œ κ²½λ‘œμ™€ λ§€μΉ­λ˜λŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€.

# ν…ŒμŠ€νŠΈ: 각 νŒ¨ν„΄μ— λŒ€ν•΄ λ§€μΉ­λ˜λŠ” 경둜λ₯Ό 좜λ ₯ν•©λ‹ˆλ‹€.
for pattern in '^/signIn$' '^/signUp$' '^/application/.+/(STANDARD|TRAINEE)$'; do
  echo "νŒ¨ν„΄: $pattern"
  rg --files | grep -E "$pattern"
done

Length of output: 536


Script:

#!/bin/bash
# Find usages of MANAGE_RESTRICTED_PATHS and router definitions
echo "=== MANAGE_RESTRICTED_PATHS μ‚¬μš©μ²˜ 검색 ==="
rg "MANAGE_RESTRICTED_PATHS" -B 2 -A 2

echo -e "\n=== λΌμš°ν„° μ •μ˜ 검색 ==="
rg "router\.(get|post|put|delete)" -B 1 -A 1

echo -e "\n=== URL νŒ¨ν„΄μ΄ ν¬ν•¨λœ ν…ŒμŠ€νŠΈ 파일 검색 ==="
rg "signIn|signUp|STANDARD|TRAINEE" --type=test

Length of output: 816


Script:

#!/bin/bash
# isPathMatch ν•¨μˆ˜ κ΅¬ν˜„ 검색
echo "=== isPathMatch ν•¨μˆ˜ κ΅¬ν˜„ 검색 ==="
ast-grep --pattern 'function isPathMatch' -A 10

echo -e "\n=== κ΄€λ ¨ νŽ˜μ΄μ§€ 파일 검색 ==="
fd -e tsx -e ts "signIn|signUp|application" app pages src

echo -e "\n=== application 경둜 κ΄€λ ¨ 파일 검색 ==="
fd "application" -t f

Length of output: 548


Script:

#!/bin/bash
# isPathMatch ν•¨μˆ˜ κ΅¬ν˜„ λ‹€μ‹œ 검색
echo "=== isPathMatch ν•¨μˆ˜ 검색 (μˆ˜μ •λœ νŒ¨ν„΄) ==="
rg "isPathMatch" -B 3 -A 10

echo -e "\n=== 라우트 ꡬ쑰 검색 ==="
fd -t d "^(app|src)$" .
fd -t f . src -e tsx -e ts --max-depth 2

echo -e "\n=== application μ»΄ν¬λ„ŒνŠΈ/νŽ˜μ΄μ§€ 검색 ==="
rg -l "application.*/(STANDARD|TRAINEE)" --type ts --type tsx

Length of output: 1770

}
function handleApiRole(request: NextRequest): NextResponse {
const requestHeaders = new Headers(request.headers);
const role = request.cookies.get('accessToken') ? 'manage' : 'user';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

κΆŒν•œ μ„€μ • 둜직의 λ³΄μ•ˆ κ°•ν™” ν•„μš”

ν˜„μž¬ accessToken의 쑴재 μ—¬λΆ€λ‘œλ§Œ role을 manage λ˜λŠ” user둜 μ„€μ •ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. ν† ν°μ˜ μœ νš¨μ„±κ³Ό μ‹€μ œ μ‚¬μš©μžμ˜ μ—­ν• (예: κ΄€λ¦¬μž, 일반 μ‚¬μš©μž)을 κ²€μ¦ν•˜λŠ” 좔가적인 둜직이 ν•„μš”ν•©λ‹ˆλ‹€. μ΄λŠ” λ³΄μ•ˆ κ°•ν™”λ₯Ό μœ„ν•΄ μ€‘μš”ν•©λ‹ˆλ‹€.

accessToken을 κ²€μ¦ν•˜κ³  μ‚¬μš©μž 역할을 μ •ν™•ν•˜κ²Œ νŒλ‹¨ν•˜λŠ” λ‘œμ§μ„ μΆ”κ°€ν•˜μ„Έμš”. 예λ₯Ό λ“€μ–΄, 토큰을 ν•΄μ„ν•˜μ—¬ μ‚¬μš©μž 정보λ₯Ό μΆ”μΆœν•˜κ³ , ν•΄λ‹Ή μ‚¬μš©μžμ˜ κΆŒν•œμ— 따라 역할을 λΆ€μ—¬ν•˜λŠ” 방식을 κ³ λ €ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

import axios from 'axios';

export const deleteUserAccount = async () => {
const response = await axios.delete('/api/admin');
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

μ—λŸ¬ 처리 둜직 μΆ”κ°€ ν•„μš”

ν˜„μž¬ deleteUserAccount ν•¨μˆ˜λŠ” μš”μ²­ μ‹€νŒ¨ μ‹œμ˜ 처리 둜직이 μ—†μŠ΅λ‹ˆλ‹€. μ„œλ²„λ‘œλΆ€ν„° μ—λŸ¬ 응닡을 λ°›λŠ” 경우λ₯Ό λŒ€λΉ„ν•˜μ—¬ μ˜ˆμ™Έ 처리λ₯Ό μΆ”κ°€ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 try-catch 블둝을 μ‚¬μš©ν•˜μ—¬ μ—λŸ¬λ₯Ό μ²˜λ¦¬ν•˜λ„λ‘ μˆ˜μ •ν•˜μ„Έμš”:

export const deleteUserAccount = async () => {
-   const response = await axios.delete('/api/admin');
-   return response;
+   try {
+     const response = await axios.delete('/api/admin');
+     return response;
+   } catch (error) {
+     // μ—λŸ¬ 처리 둜직 μΆ”κ°€
+     throw error;
+   }
};
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const response = await axios.delete('/api/admin');
export const deleteUserAccount = async () => {
try {
const response = await axios.delete('/api/admin');
return response;
} catch (error) {
// μ—λŸ¬ 처리 둜직 μΆ”κ°€
throw error;
}
};

Comment on lines +28 to +58
export async function DELETE() {
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;

if (!accessToken) {
return NextResponse.json(
{ error: 'Access token not found' },
{ status: 401 },
);
}

try {
await apiClient.delete('/admin', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

const response = NextResponse.json({ success: true });
response.cookies.set('accessToken', '', { maxAge: 0 });
response.cookies.set('refreshToken', '', { maxAge: 0 });
return response;
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status || 500;
const message =
error.response?.data?.message || 'delete user account failed';
return NextResponse.json({ error: message }, { status });
}
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

catch λΈ”λ‘μ—μ„œ κΈ°λ³Έ 응닡이 λˆ„λ½λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

errorκ°€ AxiosError μΈμŠ€ν„΄μŠ€κ°€ μ•„λ‹Œ κ²½μš°μ— λŒ€ν•œ 응닡이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” 예기치 μ•Šμ€ 였λ₯˜κ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

  } catch (error) {
    if (error instanceof AxiosError) {
      const status = error.response?.status || 500;
      const message =
        error.response?.data?.message || 'delete user account failed';
      return NextResponse.json({ error: message }, { status });
    }
+   return NextResponse.json(
+     { error: 'Internal server error' },
+     { status: 500 }
+   );
  }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function DELETE() {
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
if (!accessToken) {
return NextResponse.json(
{ error: 'Access token not found' },
{ status: 401 },
);
}
try {
await apiClient.delete('/admin', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
const response = NextResponse.json({ success: true });
response.cookies.set('accessToken', '', { maxAge: 0 });
response.cookies.set('refreshToken', '', { maxAge: 0 });
return response;
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status || 500;
const message =
error.response?.data?.message || 'delete user account failed';
return NextResponse.json({ error: message }, { status });
}
}
}
export async function DELETE() {
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
if (!accessToken) {
return NextResponse.json(
{ error: 'Access token not found' },
{ status: 401 },
);
}
try {
await apiClient.delete('/admin', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
const response = NextResponse.json({ success: true });
response.cookies.set('accessToken', '', { maxAge: 0 });
response.cookies.set('refreshToken', '', { maxAge: 0 });
return response;
} catch (error) {
if (error instanceof AxiosError) {
const status = error.response?.status || 500;
const message =
error.response?.data?.message || 'delete user account failed';
return NextResponse.json({ error: message }, { status });
}
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
);
}
}

Comment on lines +23 to 30
<div className="relative flex w-full justify-between">
<div className="flex items-center gap-[124px] mobile:flex-col mobile:gap-[30px]">
<div className="space-y-[32px]">
<ProfileInfo label="이름" value="김진원" />
<ProfileInfo label="아이디" value="jin1234" />
<ProfileInfo label="이메일" value="[email protected]" />
</div>
</div>
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

ν•˜λ“œμ½”λ”©λœ μ‚¬μš©μž 정보λ₯Ό propsλ‚˜ μƒνƒœλ‘œ κ΄€λ¦¬ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

ν˜„μž¬ μ‚¬μš©μž 정보가 ν•˜λ“œμ½”λ”©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” μœ μ§€λ³΄μˆ˜μ„±μ„ μ €ν•˜μ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

+ interface AdminProfileProps {
+   name: string;
+   username: string;
+   email: string;
+ }
- const AdminProfile = () => {
+ const AdminProfile = ({ name, username, email }: AdminProfileProps) => {
  return (
    <div className="relative flex w-full justify-between">
      <div className="flex items-center gap-[124px] mobile:flex-col mobile:gap-[30px]">
        <div className="space-y-[32px]">
-         <ProfileInfo label="이름" value="김진원" />
-         <ProfileInfo label="아이디" value="jin1234" />
-         <ProfileInfo label="이메일" value="[email protected]" />
+         <ProfileInfo label="이름" value={name} />
+         <ProfileInfo label="아이디" value={username} />
+         <ProfileInfo label="이메일" value={email} />
        </div>
      </div>
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="relative flex w-full justify-between">
<div className="flex items-center gap-[124px] mobile:flex-col mobile:gap-[30px]">
<div className="space-y-[32px]">
<ProfileInfo label="이름" value="김진원" />
<ProfileInfo label="아이디" value="jin1234" />
<ProfileInfo label="이메일" value="[email protected]" />
</div>
</div>
interface AdminProfileProps {
name: string;
username: string;
email: string;
}
const AdminProfile = ({ name, username, email }: AdminProfileProps) => {
<div className="relative flex w-full justify-between">
<div className="flex items-center gap-[124px] mobile:flex-col mobile:gap-[30px]">
<div className="space-y-[32px]">
<ProfileInfo label="이름" value={name} />
<ProfileInfo label="아이디" value={username} />
<ProfileInfo label="이메일" value={email} />
</div>
</div>

Comment on lines +31 to +51
<div>
<button onClick={handleLogoutClick}>
<Logout />
</button>
{isToggleLogout && (
<div className="absolute right-0 top-[30px] flex h-fit flex-col gap-2 rounded-[6px] border border-gray-200 bg-white p-2 shadow-[0px_4px_4px_0px_rgba(0,_0,_0,_0.25)]">
<button
onClick={() => logout()}
className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
>
λ‘œκ·Έμ•„μ›ƒ
</button>
<button
onClick={() => deleteAccount()}
className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
>
νšŒμ›νƒˆν‡΄
</button>
</div>
)}
</div>
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

μ ‘κ·Όμ„± 및 μ‚¬μš©μž κ²½ν—˜ κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

  1. λ²„νŠΌμ— aria-label이 μ—†μŠ΅λ‹ˆλ‹€.
  2. νšŒμ›νƒˆν‡΄ μ‹œ 확인 λŒ€ν™”μƒμžκ°€ μ—†μŠ΅λ‹ˆλ‹€.
  3. λ“œλ‘­λ‹€μš΄μ΄ μ—΄λ €μžˆμ„ λ•Œ μ™ΈλΆ€ 클릭으둜 λ‹«νžˆμ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

  <div>
    <button
+     aria-label="λ‘œκ·Έμ•„μ›ƒ 메뉴"
+     aria-expanded={isToggleLogout}
      onClick={handleLogoutClick}>
      <Logout />
    </button>
    {isToggleLogout && (
      <div className="absolute right-0 top-[30px] flex h-fit flex-col gap-2 rounded-[6px] border border-gray-200 bg-white p-2 shadow-[0px_4px_4px_0px_rgba(0,_0,_0,_0.25)]">
        <button
          onClick={() => logout()}
+         aria-label="λ‘œκ·Έμ•„μ›ƒ μ‹€ν–‰"
          className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
        >
          λ‘œκ·Έμ•„μ›ƒ
        </button>
        <button
-         onClick={() => deleteAccount()}
+         onClick={() => {
+           if (window.confirm('μ •λ§λ‘œ νšŒμ›νƒˆν‡΄λ₯Ό μ§„ν–‰ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?')) {
+             deleteAccount();
+           }
+         }}
+         aria-label="νšŒμ›νƒˆν‡΄ μ‹€ν–‰"
          className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
        >
          νšŒμ›νƒˆν‡΄
        </button>
      </div>
    )}
  </div>
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div>
<button onClick={handleLogoutClick}>
<Logout />
</button>
{isToggleLogout && (
<div className="absolute right-0 top-[30px] flex h-fit flex-col gap-2 rounded-[6px] border border-gray-200 bg-white p-2 shadow-[0px_4px_4px_0px_rgba(0,_0,_0,_0.25)]">
<button
onClick={() => logout()}
className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
>
λ‘œκ·Έμ•„μ›ƒ
</button>
<button
onClick={() => deleteAccount()}
className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
>
νšŒμ›νƒˆν‡΄
</button>
</div>
)}
</div>
<div>
<button
aria-label="λ‘œκ·Έμ•„μ›ƒ 메뉴"
aria-expanded={isToggleLogout}
onClick={handleLogoutClick}>
<Logout />
</button>
{isToggleLogout && (
<div className="absolute right-0 top-[30px] flex h-fit flex-col gap-2 rounded-[6px] border border-gray-200 bg-white p-2 shadow-[0px_4px_4px_0px_rgba(0,_0,_0,_0.25)]">
<button
onClick={() => logout()}
aria-label="λ‘œκ·Έμ•„μ›ƒ μ‹€ν–‰"
className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
>
λ‘œκ·Έμ•„μ›ƒ
</button>
<button
onClick={() => {
if (window.confirm('μ •λ§λ‘œ νšŒμ›νƒˆν‡΄λ₯Ό μ§„ν–‰ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?')) {
deleteAccount();
}
}}
aria-label="νšŒμ›νƒˆν‡΄ μ‹€ν–‰"
className="w-full rounded-[6px] px-5 py-2 text-body2 text-gray-500 hover:bg-error hover:text-white"
>
νšŒμ›νƒˆν‡΄
</button>
</div>
)}
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1️⃣ Priority: High μš°μ„ μˆœμœ„ - 상 ✨ Feature μ‹ κ·œ κΈ°λŠ₯
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants