This commit is contained in:
Dax Raad
2025-09-02 18:00:48 -04:00
parent e544cccc70
commit 2e16d685eb
6 changed files with 20 additions and 18 deletions

View File

@@ -22,8 +22,8 @@ export const getActor = async (): Promise<Actor.Info> => {
const auth = await useAuthSession()
const splits = url.pathname.split("/").filter(Boolean)
if (splits[0] !== "workspace") {
if (auth.data.current) {
const current = auth.data.account[auth.data.current]
const current = auth.data.account[auth.data.current ?? ""]
if (current) {
return {
type: "account",
properties: {

View File

@@ -27,5 +27,5 @@ export async function GET(input: APIEvent) {
current: id,
}
})
return redirect("/")
return redirect("/auth")
}

View File

@@ -0,0 +1,13 @@
import { Account } from "@opencode/cloud-core/account.js"
import { redirect } from "@solidjs/router"
import type { APIEvent } from "@solidjs/start/server"
import { withActor } from "~/context/auth.withActor"
export async function GET(input: APIEvent) {
try {
const workspaces = await withActor(async () => Account.workspaces())
return redirect(`/workspace/${workspaces[0].id}`)
} catch {
return redirect("/auth/authorize")
}
}

View File

@@ -1,7 +0,0 @@
import type { APIEvent } from "@solidjs/start/server"
import { AuthClient } from "~/context/auth"
export async function GET(input: APIEvent) {
const result = await AuthClient.authorize(new URL("./callback", input.request.url).toString(), "code")
return Response.redirect(result.url, 302)
}

View File

@@ -89,11 +89,7 @@ export default function Home() {
</span>
<span data-slot="divider">&nbsp;/&nbsp;</span>
<a
href={
workspaceId()
? `/workspace/${workspaceId()}`
: "/auth/authorize"
}
href="/auth"
target="_self"
>
Sign in

View File

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