summaryrefslogtreecommitdiff
path: root/src/lib/session.ts
blob: e3d4784e0acdb0500f3df0102d07d340c0cd5ec8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Token from "./token";

const session = new Token();

export function isUserAuthenticated() {
  return session.get() != null && !session.expired();
}

export async function refreshIfExpired() {
  if(!isUserAuthenticated())
    return await session.refresh();

  return true;
}

export function presentSession() {
  return session.get() != null;
}

export function logout() {
  session.logout();
}