Skip to content

Commit

Permalink
feat: 로그인 상태로 로그인 회원가입 페이지 접속시 리다이렉트 및 액세스 토큰 갱신 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
grapefruit13 committed Mar 31, 2024
1 parent 64125b6 commit b545441
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/pages/signin/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { GetServerSidePropsContext } from 'next';

import { getAuthCookie } from '@/utils';
import { PAGE_PATHS } from '@/constants';
import { getLoggedIn, renewAccess } from '@/utils';

import SigninForm from '@/components/auth/SigninForm';

export function getServerSideProps(context: GetServerSidePropsContext) {
const { accessToken } = getAuthCookie(context);
export async function getServerSideProps(context: GetServerSidePropsContext) {
await renewAccess(context);

if (accessToken) {
if (getLoggedIn(context)) {
return {
redirect: {
destination: `/league-of-legends`,
destination: PAGE_PATHS.mainList,
permanent: false,
},
};
Expand Down
11 changes: 6 additions & 5 deletions src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { GetServerSidePropsContext } from 'next';

import { getAuthCookie } from '@/utils';
import { PAGE_PATHS } from '@/constants';
import { getLoggedIn, renewAccess } from '@/utils';

import SignupForm from '@/components/auth/SignupForm';

export function getServerSideProps(context: GetServerSidePropsContext) {
const { accessToken } = getAuthCookie(context);
export async function getServerSideProps(context: GetServerSidePropsContext) {
await renewAccess(context);

if (accessToken) {
if (getLoggedIn(context)) {
return {
redirect: {
destination: `/league-of-legends`,
destination: PAGE_PATHS.mainList,
permanent: false,
},
};
Expand Down

0 comments on commit b545441

Please sign in to comment.