dev #758

Merged
ysCha merged 9 commits from dev into prd-deploy 2026-04-08 10:22:11 +09:00
Showing only changes of commit afe0a377db - Show all commits

View File

@ -6,6 +6,11 @@ import { useAxios } from '@/hooks/useAxios'
import { logout } from '@/lib/authActions'
import Cookies from 'js-cookie'
/**
* 로그아웃 처리 Hook
* - 로그아웃 API 호출 성공/실패 상관없이 로그아웃 처리
* - Header, ChangePasswordPop 등에서 공통으로 사용
*/
export function useLogout() {
const [sessionState] = useRecoilState(sessionStore)
const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState)
@ -15,22 +20,24 @@ export function useLogout() {
const logoutProcess = async () => {
const param = {
loginId: sessionState.userId,
requestId: Cookies.get('sessionId'),
requestId: Cookies.get('sessionId'), // 로그인 시 저장한 sessionId
}
// 로그아웃 API 호출 (실패해도 로그아웃 진행)
try {
await promisePost({ url: '/api/login/v1.0/logout', data: param })
} catch (error) {
console.log('logout api error:', error)
}
// 물건검색 상태 초기화
setStuffSearch({
...stuffSearch,
code: 'DELETE',
})
Cookies.remove('sessionId')
await logout()
window.location.href = '/login'
Cookies.remove('sessionId') // sessionId 쿠키 삭제
await logout() // iron-session 세션 파기
window.location.href = '/login' // 로그인 페이지로 이동 (full reload)
}
return { logoutProcess }