auth.js 455 Bytes
Newer Older
seoyeon's avatar
seoyeon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import axios from 'axios'

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

export async function handleLogout() {
  alert("로그아웃되었습니다.")
  localStorage.removeItem('loginStatus')
  await axios.get('/api/auth/logout') 
  window.location.href='/'
}

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