auth.js 448 Bytes
Newer Older
seoyeon's avatar
seoyeon committed
1
2
3
4
5
6
7
8
import axios from 'axios'

export function handleLogin(userId) {
  localStorage.setItem("user", userId)
}

export async function handleLogout() {
  alert("로그아웃되었습니다.")
seoyeon's avatar
0727    
seoyeon committed
9
  localStorage.removeItem("user")
seoyeon's avatar
seoyeon committed
10
11
12
13
14
15
16
17
18
19
20
21
  await axios.get('/api/auth/logout') 
  window.location.href='/'
}

export function isAuthenticated() {
  const userId = localStorage.getItem('loginStatus')
  if (userId) {
      return userId
  }else{
      return false
  }
}