mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 03:04:21 +01:00
wip: zen
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -27,5 +27,5 @@ export async function GET(input: APIEvent) {
|
||||
current: id,
|
||||
}
|
||||
})
|
||||
return redirect("/")
|
||||
return redirect("/auth")
|
||||
}
|
||||
|
||||
13
cloud/app/src/routes/auth/index.ts
Normal file
13
cloud/app/src/routes/auth/index.ts
Normal 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")
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -89,11 +89,7 @@ export default function Home() {
|
||||
</span>
|
||||
<span data-slot="divider"> / </span>
|
||||
<a
|
||||
href={
|
||||
workspaceId()
|
||||
? `/workspace/${workspaceId()}`
|
||||
: "/auth/authorize"
|
||||
}
|
||||
href="/auth"
|
||||
target="_self"
|
||||
>
|
||||
Sign in
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user