Skip to content

Commit

Permalink
HOTFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
yeyounging committed Nov 28, 2024
1 parent f528aab commit 7e7e979
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/app/auth/callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function LoginCheck() {

const data = await res.json()
Cookies.set('accessToken', data.data.accessToken)
Cookies.set('role', data.data.userInfo.role)
setUserInfo({
...data.data.userInfo,
profileImage:
Expand Down
2 changes: 1 addition & 1 deletion src/app/home/components/TimeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { categoryLabels } from '@/app/archive/api/types'
import { Badge, Cup, Div } from '@/components'
import { Badge, Div } from '@/components'
import Image from 'next/image'

interface TimeCardProps {
Expand Down
1 change: 0 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default function Home() {
const [logoColor, setlogoColor] = useState('white')

useEffect(() => {

const timer = setTimeout(() => {
setIsSplash(false)
}, 1200)
Expand Down
2 changes: 2 additions & 0 deletions src/app/start/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Cookies from 'js-cookie'
import { http } from '@/api'
import useUserInfo, { UserInfo } from '@/store/useUserInfo'
import { useMutation, useSuspenseQuery } from '@tanstack/react-query'
Expand All @@ -24,6 +25,7 @@ export const usePostOnboard = () => {
onSuccess: ({ data }) => {
const updatedUserInfo = { ...data, role: 'MEMBER' as const }
setUserInfo(updatedUserInfo)
Cookies.set('role', 'MEMBER')
router.push('/home')
},
onError: (error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/start/components/Step3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Step3() {
useProfileSelector()

return (
<div className=" px-20 w-full flex flex-col relative]">
<div className="px-20 w-full flex flex-col relative">
<h1 className="title !mb-6">어떤 프로필로 함께 하시겠어요?</h1>
<h2 className="text-primary_foundation_50 text-sm font-medium leading-snug">
프로필은 나중에 바꿀 수 있어요
Expand Down
4 changes: 0 additions & 4 deletions src/app/start/components/Step4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import Image from 'next/image'
export default function Step4() {
const { userInfo } = useUserInfo()

if (!userInfo.nickname) {
return <div>loading...</div>
}

return (
<div className="relative h-screen">
<div className="absolute w-screen h-full bg-gradient-to-b from-white via-[#fffbfb] to-[#ffa89c]" />
Expand Down
2 changes: 1 addition & 1 deletion src/app/start/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function Start() {
</If>
</div>

<div className="w-full py-4 flex justify-center">
<div className="w-full pt-10 flex justify-center relative">
<Button
className="w-[90%] mx-auto"
disabled={!!error}
Expand Down
31 changes: 31 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export function middleware(req: NextRequest) {
const token = req.cookies.get('accessToken')?.value
const role = req.cookies.get('role')?.value
const response = NextResponse.next()
const { pathname } = req.nextUrl

if (
pathname.startsWith('/_next') ||
pathname.startsWith('/static') ||
pathname.includes('.')
) {
return response
}

if (pathname !== '/') {
if (!token) {
return NextResponse.redirect('/')
}
}

if (pathname !== '/start' && role === 'MEMBER') {
return NextResponse.redirect(new URL('/start', req.url))
}

return NextResponse.next()
}

export const config = {}

0 comments on commit 7e7e979

Please sign in to comment.