Feature: User auth #15

Merged
scott merged 29 commits from scott/kalkutago:feature/user-auth into main 2023-08-27 12:00:57 +00:00
2 changed files with 11 additions and 0 deletions
Showing only changes of commit 290218eefe - Show all commits

View file

@ -2,6 +2,7 @@ import { reactive } from "vue"
import { Track } from "./track"
Review

Have you tried out vuex or the newer pinia yet?

Have you tried out vuex or the newer pinia yet?
Review

It's been a while since I looked into it, but I think I remember reading something in their docs which suggested that they might be overkill for this situation.

It's been a while since I looked into it, but I think I remember reading something in their docs which suggested that they might be overkill for this situation.
import { Tick } from './ticks'
import { error } from "./error"
import { getCookie } from "./util";
enum State {
Unfetched,
@ -31,6 +32,8 @@ class AppState {
constructor() {
this.tracks = new Array<Track>
this.state = State.Unfetched
const name = getCookie("name")
if (name) this.user = { name }
}
streamUpdatesFromServer() {
const source = new EventSource("/api/v1/updates")

8
client/src/util.ts Normal file
View file

@ -0,0 +1,8 @@
export function getCookie(key: string): string | null {
const start = document.cookie.indexOf(key + '=')
if(start === -1) return null
let end: number | undefined = document.cookie.indexOf(';', start)
if(end === -1)
end = undefined
return document.cookie.substring(start + key.length + 1, end)
}