summaryrefslogtreecommitdiffhomepage
path: root/cloud/app/src/context
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-09-03 13:10:57 -0400
committerDax Raad <[email protected]>2025-09-03 13:10:57 -0400
commit48a79b11738c3e55f25b49497b8ff78dfaee1222 (patch)
treeb5991665a2843c7edecd157c84bda5138ccd5d68 /cloud/app/src/context
parent59e550271d3c9bc50ebb8b7ba0d04eacd1e49e1a (diff)
downloadopencode-48a79b11738c3e55f25b49497b8ff78dfaee1222.tar.gz
opencode-48a79b11738c3e55f25b49497b8ff78dfaee1222.zip
wip: make less shit
Diffstat (limited to 'cloud/app/src/context')
-rw-r--r--cloud/app/src/context/auth.ts10
-rw-r--r--cloud/app/src/context/auth.withActor.ts5
2 files changed, 5 insertions, 10 deletions
diff --git a/cloud/app/src/context/auth.ts b/cloud/app/src/context/auth.ts
index e80604f8b..e08d965b8 100644
--- a/cloud/app/src/context/auth.ts
+++ b/cloud/app/src/context/auth.ts
@@ -14,17 +14,14 @@ export const AuthClient = createClient({
issuer: import.meta.env.VITE_AUTH_URL,
})
-export const getActor = async (): Promise<Actor.Info> => {
+export const getActor = async (workspace?: string): Promise<Actor.Info> => {
"use server"
const evt = getRequestEvent()
if (!evt) throw new Error("No request event")
if (evt.locals.actor) return evt.locals.actor
evt.locals.actor = (async () => {
- console.log("getActor")
- const url = new URL(evt.request.headers.has("x-server-id") ? evt.request.headers.get("referer")! : evt.request.url)
const auth = await useAuthSession()
- const splits = url.pathname.split("/").filter(Boolean)
- if (splits[0] !== "workspace") {
+ if (!workspace) {
const account = auth.data.account ?? {}
const current = account[auth.data.current ?? ""]
if (current) {
@@ -55,7 +52,6 @@ export const getActor = async (): Promise<Actor.Info> => {
properties: {},
}
}
- const workspaceHint = splits[1]
const accounts = Object.keys(auth.data.account ?? {})
if (accounts.length) {
const result = await Database.transaction(async (tx) => {
@@ -66,7 +62,7 @@ export const getActor = async (): Promise<Actor.Info> => {
.from(AccountTable)
.innerJoin(UserTable, and(eq(UserTable.email, AccountTable.email)))
.innerJoin(WorkspaceTable, eq(WorkspaceTable.id, UserTable.workspaceID))
- .where(and(inArray(AccountTable.id, accounts), eq(WorkspaceTable.id, workspaceHint)))
+ .where(and(inArray(AccountTable.id, accounts), eq(WorkspaceTable.id, workspace)))
.limit(1)
.execute()
.then((x) => x[0])
diff --git a/cloud/app/src/context/auth.withActor.ts b/cloud/app/src/context/auth.withActor.ts
index 5c87f1338..4cfd5c3e0 100644
--- a/cloud/app/src/context/auth.withActor.ts
+++ b/cloud/app/src/context/auth.withActor.ts
@@ -1,8 +1,7 @@
import { Actor } from "@opencode/cloud-core/actor.js"
import { getActor } from "./auth"
-import { getRequestEvent } from "solid-js/web"
-export async function withActor<T>(fn: () => T) {
- const actor = await getActor()
+export async function withActor<T>(fn: () => T, workspace?: string) {
+ const actor = await getActor(workspace)
return Actor.provide(actor.type, actor.properties, fn)
}