로그인 세션 값 체크 처리 수정 #534

This commit is contained in:
LEEYONGJAE 2025-02-03 16:27:25 +09:00
parent 4c1708d0dd
commit 9042a94c05
2 changed files with 9 additions and 5 deletions

View File

@ -55,10 +55,6 @@ export default async function RootLayout({ children }) {
redirect('/login')
}
if (headerPathname === '/login' && session.isLoggedIn) {
redirect('/')
}
return (
<RecoilRootWrapper>
<GlobalDataProvider>

View File

@ -5,7 +5,7 @@ import Image from 'next/image'
import Link from 'next/link'
import { useRecoilState } from 'recoil'
import { useAxios } from '@/hooks/useAxios'
import { setSession, login } from '@/lib/authActions'
import { setSession, login, checkSession } from '@/lib/authActions'
import { useMessage } from '@/hooks/useMessage'
import { globalLocaleStore } from '@/store/localeAtom'
import { sessionStore } from '@/store/commonAtom'
@ -21,11 +21,19 @@ export default function Login() {
//
const initParams = useSearchParams()
const autoLoginParam = initParams.get('autoLoginParam1')
useEffect(() => {
if (autoLoginParam) {
autoLoginProcess(autoLoginParam)
}
checkSession().then((res) => {
if (res) {
login()
}
})
}, [])
const autoLoginProcess = async (autoLoginParam) => {
await promisePost({ url: '/api/login/v1.0/user/login/autoLoginDecryptData', data: { loginId: autoLoginParam } })
.then((res) => {