import axios from "axios"

//자동으로 localstorage에 login이 생성됨
export function handleLogin(data) {
    sessionStorage.setItem('userId', data.user._id)
    sessionStorage.setItem('name', data.user.username)
}


export async function handleLogout() {
    sessionStorage.clear();
    await axios.get('/auth/logout')
}

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