Skip to content

Commit 6a5c1a7

Browse files
committed
fix: auth routing
1 parent 6324d1c commit 6a5c1a7

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

packages/console/app/src/component/header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function Header(props: { zen?: boolean; hideGetStarted?: boolean }) {
167167
<li>
168168
<Switch>
169169
<Match when={props.zen}>
170-
<a href={language.route("/auth")}>{i18n.t("nav.login")}</a>
170+
<a href="/auth">{i18n.t("nav.login")}</a>
171171
</Match>
172172
<Match when={!props.zen}>
173173
<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>
@@ -263,7 +263,7 @@ export function Header(props: { zen?: boolean; hideGetStarted?: boolean }) {
263263
<li>
264264
<Switch>
265265
<Match when={props.zen}>
266-
<a href={language.route("/auth")}>{i18n.t("nav.login")}</a>
266+
<a href="/auth">{i18n.t("nav.login")}</a>
267267
</Match>
268268
<Match when={!props.zen}>
269269
<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>

packages/console/app/src/routes/auth/[...callback].ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { redirect } from "@solidjs/router"
22
import type { APIEvent } from "@solidjs/start/server"
33
import { AuthClient } from "~/context/auth"
44
import { useAuthSession } from "~/context/auth"
5+
import { fromPathname, localeFromRequest, route } from "~/lib/language"
56

67
export async function GET(input: APIEvent) {
78
const url = new URL(input.request.url)
9+
const locale = localeFromRequest(input.request)
810

911
try {
1012
const code = url.searchParams.get("code")
@@ -28,7 +30,9 @@ export async function GET(input: APIEvent) {
2830
current: id,
2931
}
3032
})
31-
return redirect(url.pathname === "/auth/callback" ? "/auth" : url.pathname.replace("/auth/callback", ""))
33+
const next = url.pathname === "/auth/callback" ? "/auth" : url.pathname.replace("/auth/callback", "")
34+
if (fromPathname(next)) return redirect(next)
35+
return redirect(route(locale, next))
3236
} catch (e: any) {
3337
return new Response(
3438
JSON.stringify({
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { redirect } from "@solidjs/router"
22
import type { APIEvent } from "@solidjs/start/server"
33
import { getLastSeenWorkspaceID } from "../workspace/common"
4+
import { localeFromRequest, route } from "~/lib/language"
45

56
export async function GET(input: APIEvent) {
7+
const locale = localeFromRequest(input.request)
68
try {
79
const workspaceID = await getLastSeenWorkspaceID()
8-
return redirect(`/workspace/${workspaceID}`)
10+
return redirect(route(locale, `/workspace/${workspaceID}`))
911
} catch {
10-
return redirect("/auth/authorize")
12+
const cont = route(locale, "/auth")
13+
if (cont === "/auth") return redirect("/auth/authorize")
14+
return redirect(`/auth/authorize?continue=${encodeURIComponent(cont)}`)
1115
}
1216
}

packages/console/app/src/routes/temp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function Home() {
5151
<img data-slot="logo dark" src={logoDark} alt="opencode logo dark" />
5252
<h1 data-slot="title">{i18n.t("temp.hero.title")}</h1>
5353
<div data-slot="login">
54-
<a href={language.route("/auth")}>{i18n.t("temp.zen")}</a>
54+
<a href="/auth">{i18n.t("temp.zen")}</a>
5555
</div>
5656
</section>
5757

@@ -60,7 +60,7 @@ export default function Home() {
6060
<a href={language.route("/docs")}>{i18n.t("temp.getStarted")}</a>
6161
</div>
6262
<div data-slot="center">
63-
<a href={language.route("/auth")}>{i18n.t("temp.zen")}</a>
63+
<a href="/auth">{i18n.t("temp.zen")}</a>
6464
</div>
6565
<div data-slot="right">
6666
<button data-copy data-slot="command">

packages/console/app/src/routes/zen/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default function Home() {
122122
</svg>
123123
</div>
124124
</div>
125-
<a href={language.route("/auth")}>
125+
<a href="/auth">
126126
<span>{i18n.t("zen.cta.start")}</span>
127127
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
128128
<path
@@ -304,7 +304,7 @@ export default function Home() {
304304
{i18n.t("zen.faq.a4.p1.beforePricing")}{" "}
305305
<a href={language.route("/docs/zen/#pricing")}>{i18n.t("zen.faq.a4.p1.pricingLink")}</a>{" "}
306306
{i18n.t("zen.faq.a4.p1.afterPricing")} {i18n.t("zen.faq.a4.p2.beforeAccount")}{" "}
307-
<a href={language.route("/auth")}>{i18n.t("zen.faq.a4.p2.accountLink")}</a>. {i18n.t("zen.faq.a4.p3")}
307+
<a href="/auth">{i18n.t("zen.faq.a4.p2.accountLink")}</a>. {i18n.t("zen.faq.a4.p3")}
308308
</Faq>
309309
</li>
310310
<li>

0 commit comments

Comments
 (0)