Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
import { writable } from "svelte/store"; | |
import cookies from "js-cookie"; | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
export const userStore = writable<any>(null); | |
export const openWindowLogin = async () => { | |
return window.open( | |
"/api/auth/login", | |
"Login to LoRAs Studio", | |
"menubar=no,width=500,height=777,location=no,resizable=no,scrollbars=yes,status=no" | |
); | |
}; | |
export const loginFromCode = async (code: string) => { | |
const request = await fetch(`/api/auth?code=${code}`); | |
const { ok, token } = await request.json(); | |
if (ok) { | |
cookies.set("hf_access_token", token, { expires: 1 }); | |
window.location.reload(); | |
} | |
}; |