Auth.js 759 Bytes
Newer Older
1
2
import axios from "axios";
import Swal from "sweetalert2";
Spark's avatar
Spark committed
3
import { routesClient } from './../routesClient';
4
5
6


export function isLogined() {
7
8
9
10
11
12
  const whetherlogin = localStorage.getItem("login");
  if (whetherlogin === "false") {
    return false;
  } else {
    return true;
  }
13
}
Spark's avatar
Spark committed
14

15
export async function localLogout() {
Spark's avatar
Spark committed
16
  await axios.get(routesClient.logout).then(function () {
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    localStorage.clear();
    Swal.fire({
      title: "로그아웃 성공!",
      text: "🙏 안녕히 가세요 🙏",
      icon: "warning",
      customClass: "swal-wide",
      confirmButtonText: "확인",
    }).then((res) => {
      if (res.isConfirmed) {
        window.location.replace("/");
      } else {
        window.location.replace("/");
      }
    });
  });
32
}