summaryrefslogtreecommitdiff
path: root/fig-frontend/client/src/components/login.ts
blob: 195c97f1b16d38abda4e80ac3a773b74f2a55a52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators.js";

import * as Config from "../config";
import * as Twitch from "../twitch";

@customElement("fig-login")
export class Login extends LitElement {
  static styles = css`
  `;

  login() {
    Twitch.startTwitchAuth();
  }

  async check() {
    const resp = await fetch(`${Config.API_URL}/check`);
    console.log(await resp.text());
  }

  render() {
    const token = Twitch.getAuthToken();
    console.log(token);
    if (token) {
      return html`
<button @click=${this.check}>check token</button>
`;
    } else {
      return html`
<button @click=${this.login}>login</button>
`;
    }
  }
}