making login work for prod

This commit is contained in:
metacryst
2026-03-16 07:56:40 -05:00
parent a626abe1c3
commit 69b359d9a1
9 changed files with 81 additions and 23 deletions

View File

@@ -2,6 +2,8 @@ import Socket from "/_/code/ws/Socket.js"
import "./Home/Home.js"
import "./Home/Login.js"
import "./Home/ConnectionError.js"
import util from "./util.js"
const env = import.meta.env
let Global = class {
@@ -38,7 +40,6 @@ let Global = class {
}
onNavigate = async () => {
let selectedNetwork = this.networkFromPath()
if(!selectedNetwork) {
@@ -117,9 +118,8 @@ let Global = class {
}
async getProfile() {
console.log(env)
try {
const res = await fetch(`${env.VITE_API_URL}/profile`, {
const res = await util.authFetch(`${env.VITE_API_URL}/profile`, {
method: "GET",
credentials: "include",
headers: {
@@ -142,6 +142,16 @@ let Global = class {
}
}
async onLogin() {
if(!this.profile) {
await this.getProfile()
}
await this.Socket.init()
await this.onNavigate()
Home()
// navigateTo("/")
}
constructor() {
window.addEventListener("navigate", this.onNavigate)
@@ -151,10 +161,7 @@ let Global = class {
} else if(status === 500) {
ConnectionError()
} else {
console.log("else")
await this.Socket.init()
await this.onNavigate()
Home()
this.onLogin()
}
})
}