-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import SignButton from "@/components/SignButton"; | ||
|
||
const SignError = () => { | ||
return ( | ||
<section> | ||
<p>오류가 발생했습니다. 다시 로그인 해주세요.</p> | ||
<SignButton /> | ||
</section> | ||
); | ||
}; | ||
|
||
export default SignError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SignInSection from "@/templates/SignInSection"; | ||
|
||
const SignIn = () => { | ||
return <SignInSection />; | ||
}; | ||
|
||
export default SignIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { getToken } from "next-auth/jwt"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
const withAuthList = ["/browse", "/album", "/addAlbum", "/addMate"]; | ||
const withOutAuthList = ["/signIn"]; | ||
|
||
const withAuth = async (req: NextRequest, token: boolean) => { | ||
const url = req.nextUrl.clone(); | ||
|
||
if (!token) { | ||
url.pathname = "/signIn"; | ||
|
||
return NextResponse.redirect(url); | ||
} | ||
}; | ||
|
||
const withOutAuth = async (req: NextRequest, token: boolean) => { | ||
const url = req.nextUrl.clone(); | ||
|
||
if (token) { | ||
return NextResponse.redirect(url.origin); | ||
} | ||
}; | ||
|
||
export default async function middleware(req: NextRequest) { | ||
const token = await getToken({ req }); | ||
const pathname = req.nextUrl.pathname; | ||
|
||
const isWithAuth = withAuthList.includes(pathname); | ||
const isWithOutAuth = withOutAuthList.includes(pathname); | ||
|
||
if (isWithAuth) return withAuth(req, !!token); | ||
if (isWithOutAuth) return withOutAuth(req, !!token); | ||
} | ||
|
||
export const config = { | ||
matcher: [...withAuthList, ...withOutAuthList], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use client"; | ||
|
||
import Image from "next/image"; | ||
import KakaoLoginBtn from "../../../public/images/sign/kakao_login_btn.png"; | ||
import NaverLoginBtn from "../../../public/images/sign/naver_login_btn.png"; | ||
import { signIn } from "next-auth/react"; | ||
|
||
const SignInBox = () => { | ||
return ( | ||
<div> | ||
<Image | ||
src={KakaoLoginBtn} | ||
alt="카카오 로그인" | ||
className="mb-[15px] cursor-pointer" | ||
width={330} | ||
onClick={() => signIn("kakao")} | ||
/> | ||
|
||
<Image | ||
src={NaverLoginBtn} | ||
alt="네이버 로그인" | ||
className="cursor-pointer" | ||
width={330} | ||
onClick={() => signIn("naver")} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SignInBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Image from "next/image"; | ||
import SignInLogo from "../../../public/images/sign/signIn-logo.png"; | ||
import SignInBox from "./SignInBox"; | ||
|
||
const SignInSection = () => { | ||
return ( | ||
<section className="w-full h-full flex flex-col items-center justify-center gap-[55px] mt-[-80px]"> | ||
<div className="text-center"> | ||
<Image src={SignInLogo} alt="로고" /> | ||
<p className="text-[24px]">로그인</p> | ||
</div> | ||
<SignInBox /> | ||
</section> | ||
); | ||
}; | ||
|
||
export default SignInSection; |