Skip to content

Commit

Permalink
Feat: 로그인한 유저가 로그인 페이지로 왔을 때 핸들링
Browse files Browse the repository at this point in the history
  • Loading branch information
soulchicken committed Oct 25, 2023
1 parent b7d4347 commit ecc811c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/components/account/socialLoginButton/GoogleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const GoogleButton = () => {
const googleLoginHandler = () => {
setToastMessage('소셜로그인은 추후에 제공될 예정입니다. :)');
// signIn('google', {
// callbackUrl: '/friends',
// callbackUrl: '/',
// redirect: false,
// });
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/socialLoginButton/KakaoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const KakaoButton = () => {
const kakaoLoginHandler = () => {
setToastMessage('소셜로그인은 추후에 제공될 예정입니다. :)');
// signIn('kakao', {
// callbackUrl: '/friends',
// callbackUrl: '/',
// redirect: false,
// });
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/socialLoginButton/NaverButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NaverButton = () => {
const naverLoginHandler = () => {
setToastMessage('소셜로그인은 추후에 제공될 예정입니다. :)');
// signIn('naver', {
// callbackUrl: '/friends',
// callbackUrl: '/',
// redirect: false,
// });
};
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const withOutAuth = async (req:NextRequest, token: boolean) => {
const url = req.nextUrl.clone();

if (token) {
url.pathname = '/friends';
url.pathname = '/';

return NextResponse.redirect(url);
}
Expand Down
73 changes: 46 additions & 27 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,53 @@ import Link from 'next/link';
import Image from 'next/image';
import SEO from '@/components/common/head/SEO';
import Button from '@/components/common/button/Button';
import { useSession } from 'next-auth/react';

const Home = () => (
<>
<SEO title="Home" />
<section css={pageCSS}>
<main css={css`justify-content:center; margin:auto 0;`}>
<Image
src="/thumbnail.png"
alt="썸네일"
width={295}
height={150}
/>
</main>
<footer css={css`width:100%; padding: 1.5rem;`}>
<Link href="/login">
<Button theme="green">
Log in
</Button>
</Link>
<Link href="/chats/0">
<Button theme="white">
영준이와 대화하기
</Button>
</Link>
</footer>
</section>
</>
);
const Home = () => {
console.log();
const { data: session }: any = useSession();

return (
<>
<SEO title="Home" />
<section css={pageCSS}>
<main css={css`justify-content:center; margin:auto 0;`}>
<Image
src="/thumbnail.png"
alt="썸네일"
width={295}
height={150}
/>
</main>
<footer css={css`width:100%; padding: 1.5rem;`}>
{
session
? (
<>
<Link href="/friends">
<Button theme="green">
시작하기
</Button>
</Link>
<Link href="/chats/0">
<Button theme="white">
영준이와 대화하기
</Button>
</Link>
</>
) : (
<Link href="/login">
<Button theme="green">
Log in
</Button>
</Link>
)
}
</footer>
</section>
</>
);
};

export default Home;

Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Login = () => {
signIn('credentials', {
email,
password,
callbackUrl: '/friends',
callbackUrl: '/',
});
};
return (
Expand Down

0 comments on commit ecc811c

Please sign in to comment.