Skip to content

Commit

Permalink
Merge pull request #136 from jeiltodo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Dragonite-Lee authored Aug 28, 2024
2 parents f94fe46 + b4fd0ee commit 3be2f8b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 20 deletions.
File renamed without changes
File renamed without changes
2 changes: 2 additions & 0 deletions apps/admin/src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { SidebarAdmin } from '../../widgets/sidebar/ui/sidebar-admin';
import { userOptions } from '../../entities/user';
import { getQueryClient } from '@jeiltodo/ui/entities';

export const runtime = 'edge';

export default async function DashboardLayout({
children,
}: {
Expand Down
26 changes: 15 additions & 11 deletions apps/admin/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

// 관리자 보호 경로 목록 (basePath 적용)
const protectedAdminRoutes = [
'/',
'/goals',
'/group',
'/members',
];
const protectedAdminRoutes = ['/', '/goals', '/group', '/members'];

// 관리자 공개 경로 목록 (basePath 적용)
const publicAdminRoutes = ['/login'];
Expand All @@ -16,13 +11,18 @@ export function middleware(request: NextRequest) {
const token = request.cookies.get('accessAdminToken')?.value;
const path = request.nextUrl.pathname;

console.log('\n');
console.log('path: ', path);
console.log('관리자 Middleware running');
console.log('Request URL:', path);
console.log('Token:', token);

// 보호된 관리자 경로에 접근 시 토큰 체크
if (protectedAdminRoutes.some(route => path === route || path.startsWith(`${route}/`))) {
if (
protectedAdminRoutes.some(
(route) => path === route || path.startsWith(`${route}/`)
)
) {
if (!token) {
console.log('Redirecting to /admin/login');
return NextResponse.redirect(new URL('/admin/login', request.url));
Expand All @@ -31,10 +31,14 @@ export function middleware(request: NextRequest) {
}

// 로그인한 관리자가 로그인 페이지에 접근하려 할 때 관리자 대시보드로 리다이렉트
if (publicAdminRoutes.some(route => path === route || path.startsWith(`${route}/`))) {
if (
publicAdminRoutes.some(
(route) => path === route || path.startsWith(`${route}/`)
)
) {
if (token) {
console.log('Redirecting to /admin');
// return NextResponse.redirect(new URL('/admin', request.url));
// console.log('Redirecting to /admin');
return NextResponse.redirect(new URL('/admin', request.url));
}
}

Expand All @@ -43,5 +47,5 @@ export function middleware(request: NextRequest) {
}

export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico|logo.png|s-logo.png).*)'],
matcher: ['/'],
};
2 changes: 2 additions & 0 deletions apps/user/src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
progressAllOptions,
} from '../../entities/goal';

export const runtime = 'edge';

export default async function DashboardLayout({
children,
}: {
Expand Down
2 changes: 1 addition & 1 deletion apps/user/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ export function middleware(request: NextRequest) {

// 모든 경로에 대해 미들웨어 적용
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
matcher: ['/'],
};
2 changes: 1 addition & 1 deletion apps/user/src/page/auth/signup-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const SignUpPage: React.FC = () => {
return (
<div className='flex flex-col items-center desktop:py-[120px] tablet:py-16 tablet:px-[52px] py-12 px-4'>
<h1 className='mb-[60px]'>
<Image src='/logo.png' alt='Logo' width={180} height={50} />
<Image src='/assets/logo.png' alt='Logo' width={180} height={50} />
</h1>
<SignUpForm onSubmit={onSignUp} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/page/auth/login-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const LoginPage: React.FC<LoginPageProps> = ({ type }) => {
<div className='flex flex-col items-center desktop:py-[120px] tablet:py-16 tablet:px-[52px] py-12 px-4'>
<h1 className='mb-[60px] flex items-center gap-5'>
<Image
src={type === 'admin' ? '/admin/logo.png' : '/logo.png'}
src={type === 'admin' ? '/admin/assets/logo.png' : '/logo.png'}
alt='Logo'
width={180}
height={50}
Expand Down
10 changes: 5 additions & 5 deletions packages/ui/src/shared/ui/@x/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const Sidebar = ({ type, children }: SidebarProps) => {
className={`items-center gap-2 ${isDesktopOpen ? 'flex' : 'hidden'} `}
>
<Image
src={type ? '/admin/logo.png' : '/logo.png'}
src={type ? '/admin/assets/logo.png' : '/logo.png'}
alt='Logo'
width={100}
height={30}
Expand All @@ -73,7 +73,7 @@ export const Sidebar = ({ type, children }: SidebarProps) => {
)}
</div>
<Image
src={type ? '/admin/s-logo.png' : '/s-logo.png'}
src={type ? '/admin/assets/s-logo.png' : '/s-logo.png'}
alt='Logo'
width={24}
height={24}
Expand Down Expand Up @@ -118,7 +118,7 @@ export const Sidebar = ({ type, children }: SidebarProps) => {
className={`items-center gap-2 ${isTabletOpen ? 'flex' : 'hidden'}`}
>
<Image
src={type ? '/admin/logo.png' : '/logo.png'}
src={type ? '/admin/assets/logo.png' : '/logo.png'}
alt='Logo'
width={100}
height={30}
Expand All @@ -138,7 +138,7 @@ export const Sidebar = ({ type, children }: SidebarProps) => {
)}
</div>
<Image
src={type ? '/admin/s-logo.png' : '/s-logo.png'}
src={type ? '/admin/assets/s-logo.png' : '/s-logo.png'}
alt='Logo'
width={24}
height={24}
Expand Down Expand Up @@ -199,7 +199,7 @@ export const Sidebar = ({ type, children }: SidebarProps) => {
{isMobileSidebarOpen && (
<div className='flex items-center justify-between py-3 px-4'>
<Image
src={type ? '/admin/logo.png' : '/logo.png'}
src={type ? '/admin/assets/logo.png' : '/logo.png'}
alt='Logo'
width={100}
height={30}
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

Expand Down

0 comments on commit 3be2f8b

Please sign in to comment.