auth.js 434 Bytes
Newer Older
이재연's avatar
이재연 committed
1
2
import axios from "axios"

이재연's avatar
이재연 committed
3
4
export function handleLogin(userId){
    localStorage.setItem('loginStatus',userId)
이재연's avatar
이재연 committed
5
6
7
8
9
}

export async function handleLogout(){
    localStorage.removeItem('loginStatus')
    await axios.get('/api/auth/logout')
이재연's avatar
이재연 committed
10
11
12
13
14
15
16
17
18
19
    window.location.href='/'
}

export function isAuthenticated(){
    const userId= localStorage.getItem('loginStatus')
    if(userId){
        return userId
    } else{
        return false
    }
이재연's avatar
이재연 committed
20
}