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

export function handleLogin(userId) {
    localStorage.setItem('loginStatus', userId)
}

export async function handleLogout() {
    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
    }
}