Compare commits
No commits in common. "104f5a115c7638e0e397e8ea22c5187cb561eea2" and "e7c4202fb59ea1cc1884a068f326a5799ccefd62" have entirely different histories.
104f5a115c
...
e7c4202fb5
@ -3,7 +3,6 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { setSession, login } from '@/lib/authActions'
|
import { setSession, login } from '@/lib/authActions'
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
import { sessionStore } from '@/store/commonAtom'
|
import { sessionStore } from '@/store/commonAtom'
|
||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
@ -32,7 +31,6 @@ export default function AutoLoginPage({ autoLoginParam }) {
|
|||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
const res = response.data
|
const res = response.data
|
||||||
if (res.sessionId) Cookies.set('sessionId', res.sessionId)
|
|
||||||
const result = { ...res, storeLvl: res.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
const result = { ...res, storeLvl: res.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
||||||
setSession(result)
|
setSession(result)
|
||||||
setSessionState(result)
|
setSessionState(result)
|
||||||
|
|||||||
@ -48,7 +48,6 @@ export default function Login() {
|
|||||||
post({ url: '/api/login/v1.0/user', data: { loginId: res.data } }).then((response) => {
|
post({ url: '/api/login/v1.0/user', data: { loginId: res.data } }).then((response) => {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
if (response) {
|
if (response) {
|
||||||
if (response.sessionId) Cookies.set('sessionId', response.sessionId)
|
|
||||||
const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
||||||
setSession(result)
|
setSession(result)
|
||||||
setSessionState(result)
|
setSessionState(result)
|
||||||
@ -108,7 +107,7 @@ export default function Login() {
|
|||||||
if (res) {
|
if (res) {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
if (res.data.result.resultCode === 'S') {
|
if (res.data.result.resultCode === 'S') {
|
||||||
if (res.data.sessionId) Cookies.set('sessionId', res.data.sessionId)
|
Cookies.set('sessionId', res.data.sessionId)
|
||||||
setSession(res.data.data)
|
setSession(res.data.data)
|
||||||
setSessionState(res.data.data)
|
setSessionState(res.data.data)
|
||||||
// ID SAVE 체크되어 있는 경우, 쿠키 저장
|
// ID SAVE 체크되어 있는 경우, 쿠키 저장
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
|
||||||
import { sessionStore } from '@/store/commonAtom'
|
|
||||||
import { globalLocaleStore } from '@/store/localeAtom'
|
|
||||||
import { stuffSearchState } from '@/store/stuffAtom'
|
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
|
||||||
import { logout } from '@/lib/authActions'
|
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
|
|
||||||
export function useLogout() {
|
|
||||||
const [sessionState] = useRecoilState(sessionStore)
|
|
||||||
const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState)
|
|
||||||
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
|
||||||
const { promisePost } = useAxios(globalLocaleState)
|
|
||||||
|
|
||||||
const logoutProcess = async () => {
|
|
||||||
const param = {
|
|
||||||
loginId: sessionState.userId,
|
|
||||||
requestId: Cookies.get('sessionId'),
|
|
||||||
}
|
|
||||||
await promisePost({ url: '/api/login/v1.0/logout', data: param })
|
|
||||||
.then(async (res) => {
|
|
||||||
if (res.data.result.resultCode === 'S') {
|
|
||||||
setStuffSearch({
|
|
||||||
...stuffSearch,
|
|
||||||
code: 'DELETE',
|
|
||||||
})
|
|
||||||
Cookies.remove('sessionId')
|
|
||||||
await logout()
|
|
||||||
window.location.href = '/login'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
alert(error.response?.data?.message || 'ログアウトに失敗しました。')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return { logoutProcess }
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user