making login work for prod
This commit is contained in:
21
src/index.js
21
src/index.js
@@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user