auth.js 454 Bytes
Newer Older
Kim, Chaerin's avatar
merge19    
Kim, Chaerin committed
1
2
3
import axios from 'axios'

export function handleLogin(userId) {
이재연's avatar
이재연 committed
4
  sessionStorage.setItem("user", userId)
Kim, Chaerin's avatar
merge19    
Kim, Chaerin committed
5
6
7
8
}

export async function handleLogout() {
  alert("로그아웃되었습니다.")
이재연's avatar
이재연 committed
9
  sessionStorage.removeItem("user")
Kim, Chaerin's avatar
merge19    
Kim, Chaerin committed
10
11
12
13
14
  await axios.get('/api/auth/logout') 
  window.location.href='/'
}

export function isAuthenticated() {
이재연's avatar
이재연 committed
15
  const userId = sessionStorage.getItem('loginStatus')
Kim, Chaerin's avatar
merge19    
Kim, Chaerin committed
16
17
18
19
20
21
  if (userId) {
      return userId
  }else{
      return false
  }
}