ignore: cloud

This commit is contained in:
Jay V
2025-08-28 17:10:41 -04:00
parent 36ec9dddb2
commit 4d81f90dde
3 changed files with 22 additions and 27 deletions

View File

@@ -1,5 +1,3 @@
import { useSession } from "vinxi/http" import { useSession } from "vinxi/http"
import { createClient } from "@openauthjs/openauth/client" import { createClient } from "@openauthjs/openauth/client"
import { getRequestEvent } from "solid-js/web" import { getRequestEvent } from "solid-js/web"
@@ -20,7 +18,7 @@ export const getActor = query(async (): Promise<Actor.Info> => {
const evt = getRequestEvent() const evt = getRequestEvent()
const url = new URL(evt!.request.headers.get("referer") ?? evt!.request.url) const url = new URL(evt!.request.headers.get("referer") ?? evt!.request.url)
const auth = await useAuthSession() const auth = await useAuthSession()
const [workspaceHint] = url.pathname.split("/").filter((x) => x.length > 0) const [, workspaceHint] = url.pathname.split("/").filter((x) => x.length > 0)
if (!workspaceHint) { if (!workspaceHint) {
if (auth.data.current) { if (auth.data.current) {
const current = auth.data.account[auth.data.current] const current = auth.data.account[auth.data.current]
@@ -34,7 +32,7 @@ export const getActor = query(async (): Promise<Actor.Info> => {
} }
if (Object.keys(auth.data.account ?? {}).length > 0) { if (Object.keys(auth.data.account ?? {}).length > 0) {
const current = Object.values(auth.data.account)[0] const current = Object.values(auth.data.account)[0]
await auth.update(val => ({ await auth.update((val) => ({
...val, ...val,
current: current.id, current: current.id,
})) }))
@@ -53,18 +51,14 @@ export const getActor = query(async (): Promise<Actor.Info> => {
} }
const accounts = Object.keys(auth.data.account) const accounts = Object.keys(auth.data.account)
const result = await Database.transaction(async (tx) => { const result = await Database.transaction(async (tx) => {
return await tx.select({ return await tx
user: UserTable .select({
user: UserTable,
}) })
.from(AccountTable) .from(AccountTable)
.innerJoin(UserTable, and(eq(UserTable.email, AccountTable.email))) .innerJoin(UserTable, and(eq(UserTable.email, AccountTable.email)))
.innerJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID)) .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID))
.where( .where(and(inArray(AccountTable.id, accounts), eq(WorkspaceTable.id, workspaceHint)))
and(
inArray(AccountTable.id, accounts),
eq(WorkspaceTable.id, workspaceHint),
)
)
.limit(1) .limit(1)
.execute() .execute()
.then((x) => x[0]) .then((x) => x[0])
@@ -81,17 +75,19 @@ export const getActor = query(async (): Promise<Actor.Info> => {
throw redirect("/auth/authorize") throw redirect("/auth/authorize")
}, "actor") }, "actor")
export const AuthClient = createClient({ export const AuthClient = createClient({
clientID: "app", clientID: "app",
issuer: import.meta.env.VITE_AUTH_URL, issuer: import.meta.env.VITE_AUTH_URL,
}) })
export interface AuthSession { export interface AuthSession {
account: Record<string, { account: Record<
string,
{
id: string id: string
email: string email: string
}> }
>
current?: string current?: string
} }
@@ -106,7 +102,4 @@ export function useAuthSession() {
}) })
} }
export function AuthProvider() { }
export function AuthProvider() {
}

View File

@@ -23,9 +23,10 @@ function CopyStatus() {
const isLoggedIn = query(async () => { const isLoggedIn = query(async () => {
"use server" "use server"
const actor = await getActor() const actor = await getActor()
console.log(actor)
if (actor.type === "account") { if (actor.type === "account") {
const workspaces = await withActor(() => Account.workspaces()) const workspaces = await withActor(() => Account.workspaces())
throw redirect("/" + workspaces[0].id) throw redirect(`/workspace/${workspaces[0].id}`)
} }
return false return false
}, "isLoggedIn") }, "isLoggedIn")

View File

@@ -42,11 +42,12 @@ const createCheckoutUrl = action(async (successUrl: string, cancelUrl: string) =
return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl })) return withActor(() => Billing.generateCheckoutUrl({ successUrl, cancelUrl }))
}, "checkoutUrl") }, "checkoutUrl")
//export const route = { const createPortalUrl = action(async (returnUrl: string) => {
// preload: () => listKeys(), "use server"
//} return withActor(() => Billing.generatePortalUrl({ returnUrl }))
}, "portalUrl")
export default function () { export default function() {
const actor = createAsync(() => getActor()) const actor = createAsync(() => getActor())
///////////////// /////////////////