auth.js 491 Bytes
Newer Older
우지원's avatar
01_06    
우지원 committed
1
2
3
import axios from "axios"

//자동으로 localstorage에 login이 생성됨
4
5
6
export function handleLogin(data) {
    localStorage.setItem('userId', data.user._id)
    localStorage.setItem('name', data.user.username)
우지원's avatar
01_06    
우지원 committed
7
8
9
10
}


export async function handleLogout() {
11
    localStorage.clear();
12
    await axios.get('/auth/logout')
13
14
15
16
17
18
19
20
21
}

export function isAuthenticated() {
    const userId = localStorage.getItem('userId')
    if (userId) {
        return userId
    } else {
        return false
    }
우지원's avatar
01_06    
우지원 committed
22
}