fix: auth routing
This commit is contained in:
@@ -167,7 +167,7 @@ export function Header(props: { zen?: boolean; hideGetStarted?: boolean }) {
|
||||
<li>
|
||||
<Switch>
|
||||
<Match when={props.zen}>
|
||||
<a href={language.route("/auth")}>{i18n.t("nav.login")}</a>
|
||||
<a href="/auth">{i18n.t("nav.login")}</a>
|
||||
</Match>
|
||||
<Match when={!props.zen}>
|
||||
<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>
|
||||
@@ -263,7 +263,7 @@ export function Header(props: { zen?: boolean; hideGetStarted?: boolean }) {
|
||||
<li>
|
||||
<Switch>
|
||||
<Match when={props.zen}>
|
||||
<a href={language.route("/auth")}>{i18n.t("nav.login")}</a>
|
||||
<a href="/auth">{i18n.t("nav.login")}</a>
|
||||
</Match>
|
||||
<Match when={!props.zen}>
|
||||
<A href={language.route("/zen")}>{i18n.t("nav.zen")}</A>
|
||||
|
||||
@@ -2,9 +2,11 @@ import { redirect } from "@solidjs/router"
|
||||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import { AuthClient } from "~/context/auth"
|
||||
import { useAuthSession } from "~/context/auth"
|
||||
import { fromPathname, localeFromRequest, route } from "~/lib/language"
|
||||
|
||||
export async function GET(input: APIEvent) {
|
||||
const url = new URL(input.request.url)
|
||||
const locale = localeFromRequest(input.request)
|
||||
|
||||
try {
|
||||
const code = url.searchParams.get("code")
|
||||
@@ -28,7 +30,9 @@ export async function GET(input: APIEvent) {
|
||||
current: id,
|
||||
}
|
||||
})
|
||||
return redirect(url.pathname === "/auth/callback" ? "/auth" : url.pathname.replace("/auth/callback", ""))
|
||||
const next = url.pathname === "/auth/callback" ? "/auth" : url.pathname.replace("/auth/callback", "")
|
||||
if (fromPathname(next)) return redirect(next)
|
||||
return redirect(route(locale, next))
|
||||
} catch (e: any) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { redirect } from "@solidjs/router"
|
||||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import { getLastSeenWorkspaceID } from "../workspace/common"
|
||||
import { localeFromRequest, route } from "~/lib/language"
|
||||
|
||||
export async function GET(input: APIEvent) {
|
||||
const locale = localeFromRequest(input.request)
|
||||
try {
|
||||
const workspaceID = await getLastSeenWorkspaceID()
|
||||
return redirect(`/workspace/${workspaceID}`)
|
||||
return redirect(route(locale, `/workspace/${workspaceID}`))
|
||||
} catch {
|
||||
return redirect("/auth/authorize")
|
||||
const cont = route(locale, "/auth")
|
||||
if (cont === "/auth") return redirect("/auth/authorize")
|
||||
return redirect(`/auth/authorize?continue=${encodeURIComponent(cont)}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function Home() {
|
||||
<img data-slot="logo dark" src={logoDark} alt="opencode logo dark" />
|
||||
<h1 data-slot="title">{i18n.t("temp.hero.title")}</h1>
|
||||
<div data-slot="login">
|
||||
<a href={language.route("/auth")}>{i18n.t("temp.zen")}</a>
|
||||
<a href="/auth">{i18n.t("temp.zen")}</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -60,7 +60,7 @@ export default function Home() {
|
||||
<a href={language.route("/docs")}>{i18n.t("temp.getStarted")}</a>
|
||||
</div>
|
||||
<div data-slot="center">
|
||||
<a href={language.route("/auth")}>{i18n.t("temp.zen")}</a>
|
||||
<a href="/auth">{i18n.t("temp.zen")}</a>
|
||||
</div>
|
||||
<div data-slot="right">
|
||||
<button data-copy data-slot="command">
|
||||
|
||||
@@ -122,7 +122,7 @@ export default function Home() {
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<a href={language.route("/auth")}>
|
||||
<a href="/auth">
|
||||
<span>{i18n.t("zen.cta.start")}</span>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
@@ -304,7 +304,7 @@ export default function Home() {
|
||||
{i18n.t("zen.faq.a4.p1.beforePricing")}{" "}
|
||||
<a href={language.route("/docs/zen/#pricing")}>{i18n.t("zen.faq.a4.p1.pricingLink")}</a>{" "}
|
||||
{i18n.t("zen.faq.a4.p1.afterPricing")} {i18n.t("zen.faq.a4.p2.beforeAccount")}{" "}
|
||||
<a href={language.route("/auth")}>{i18n.t("zen.faq.a4.p2.accountLink")}</a>. {i18n.t("zen.faq.a4.p3")}
|
||||
<a href="/auth">{i18n.t("zen.faq.a4.p2.accountLink")}</a>. {i18n.t("zen.faq.a4.p3")}
|
||||
</Faq>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
Reference in New Issue
Block a user