wip: console

This commit is contained in:
Frank
2025-09-03 06:37:40 -04:00
parent 9ad4dc9296
commit 93f2805bc2
4 changed files with 8 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
import { useSession } from "vinxi/http" import { useSession } from "vinxi/http"
export interface AuthSession { export interface AuthSession {
account: Record< account?: Record<
string, string,
{ {
id: string id: string

View File

@@ -20,13 +20,10 @@ export const getActor = async (): Promise<Actor.Info> => {
if (!evt) throw new Error("No request event") if (!evt) throw new Error("No request event")
const url = new URL(evt.request.headers.has("x-server-id") ? evt.request.headers.get("referer")! : evt.request.url) const url = new URL(evt.request.headers.has("x-server-id") ? evt.request.headers.get("referer")! : evt.request.url)
const auth = await useAuthSession() const auth = await useAuthSession()
auth.data.account = auth.data.account ?? {}
const splits = url.pathname.split("/").filter(Boolean) const splits = url.pathname.split("/").filter(Boolean)
if (splits[0] !== "workspace") { if (splits[0] !== "workspace") {
// TODO
console.log("before current")
console.log(`current: ${auth.data.current}`)
const current = auth.data.account[auth.data.current ?? ""] const current = auth.data.account[auth.data.current ?? ""]
console.log("after current")
if (current) { if (current) {
return { return {
type: "account", type: "account",

View File

@@ -24,8 +24,6 @@ function CopyStatus() {
const isLoggedIn = query(async () => { const isLoggedIn = query(async () => {
"use server" "use server"
const actor = await getActor() const actor = await getActor()
// TODO
console.log(actor)
if (actor.type === "account") { if (actor.type === "account") {
const workspaces = await withActor(() => Account.workspaces()) const workspaces = await withActor(() => Account.workspaces())
return workspaces[0].id return workspaces[0].id

View File

@@ -22,8 +22,8 @@ const logout = action(async () => {
const current = auth.data.current const current = auth.data.current
if (current) if (current)
await auth.update((val) => { await auth.update((val) => {
delete val.account[current] delete val.account?.[current]
const first = Object.keys(val.account)[0] const first = Object.keys(val.account ?? {})[0]
val.current = first val.current = first
return val return val
}) })
@@ -43,8 +43,10 @@ export default function WorkspaceLayout(props: RouteSectionProps) {
</div> </div>
<div data-slot="header-actions"> <div data-slot="header-actions">
<span>{userInfo()?.user.email}</span> <span>{userInfo()?.user.email}</span>
<form onSubmit={() => location.href = "/"} action={logout} method="post"> <form onSubmit={() => (location.href = "/")} action={logout} method="post">
<button type="submit" formaction={logout}>Logout</button> <button type="submit" formaction={logout}>
Logout
</button>
</form> </form>
</div> </div>
</header> </header>