Revert ugly stripping by using a top level front route
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
import { Logo } from "@probo/ui";
|
import { Logo } from "@probo/ui";
|
||||||
import { Outlet } from "react-router";
|
import type { PropsWithChildren } from "react";
|
||||||
|
|
||||||
|
export function AuthLayout(props: PropsWithChildren) {
|
||||||
|
const { children } = props;
|
||||||
|
|
||||||
export default function () {
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 min-h-screen text-txt-primary">
|
<div className="grid grid-cols-1 lg:grid-cols-2 min-h-screen text-txt-primary">
|
||||||
<div className="bg-level-0 flex flex-col items-center justify-center">
|
<div className="bg-level-0 flex flex-col items-center justify-center">
|
||||||
<div className="w-full max-w-md px-6">
|
<div className="w-full max-w-md px-6">{children}</div>
|
||||||
<Outlet />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="hidden lg:flex bg-dialog font-bold flex-col items-center justify-center p-8 text-txt-primary lg:p-10">
|
<div className="hidden lg:flex bg-dialog font-bold flex-col items-center justify-center p-8 text-txt-primary lg:p-10">
|
||||||
<div className="flex flex-col items-center justify-center gap-4">
|
<div className="flex flex-col items-center justify-center gap-4">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { useMutation } from "react-relay";
|
|||||||
import { formatError } from "@probo/helpers";
|
import { formatError } from "@probo/helpers";
|
||||||
import type { VerifyMagicLinkPageMutation } from "./__generated__/VerifyMagicLinkPageMutation.graphql";
|
import type { VerifyMagicLinkPageMutation } from "./__generated__/VerifyMagicLinkPageMutation.graphql";
|
||||||
import { getPathPrefix } from "/utils/pathPrefix";
|
import { getPathPrefix } from "/utils/pathPrefix";
|
||||||
|
import { AuthLayout } from "./AuthLayout";
|
||||||
|
|
||||||
const verifyMagicLinkMutation = graphql`
|
const verifyMagicLinkMutation = graphql`
|
||||||
mutation VerifyMagicLinkPageMutation($input: VerifyMagicLinkInput!) {
|
mutation VerifyMagicLinkPageMutation($input: VerifyMagicLinkInput!) {
|
||||||
@@ -84,37 +85,39 @@ export default function VerifyMagicLinkPagePageMutation() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6 w-full max-w-md mx-auto">
|
<AuthLayout>
|
||||||
<div className="space-y-2 text-center">
|
<div className="space-y-6 w-full max-w-md mx-auto">
|
||||||
<h1 className="text-3xl font-bold">{__("Email Confirmation")}</h1>
|
<div className="space-y-2 text-center">
|
||||||
<p className="text-txt-tertiary">
|
<h1 className="text-3xl font-bold">{__("Email Confirmation")}</h1>
|
||||||
{__("Confirm your email address to complete registration")}
|
<p className="text-txt-tertiary">
|
||||||
</p>
|
{__("Confirm your email address to complete registration")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
|
<Field
|
||||||
|
label={__("Confirmation Token")}
|
||||||
|
type="text"
|
||||||
|
placeholder={__("Enter your confirmation token")}
|
||||||
|
{...form.register("token")}
|
||||||
|
error={form.formState.errors.token?.message}
|
||||||
|
disabled={form.formState.isSubmitting}
|
||||||
|
help={__(
|
||||||
|
"The token has been automatically filled from the URL if available",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full"
|
||||||
|
disabled={form.formState.isSubmitting}
|
||||||
|
>
|
||||||
|
{form.formState.isSubmitting
|
||||||
|
? __("Confirming...")
|
||||||
|
: __("Confirm Email")}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</AuthLayout>
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
|
||||||
<Field
|
|
||||||
label={__("Confirmation Token")}
|
|
||||||
type="text"
|
|
||||||
placeholder={__("Enter your confirmation token")}
|
|
||||||
{...form.register("token")}
|
|
||||||
error={form.formState.errors.token?.message}
|
|
||||||
disabled={form.formState.isSubmitting}
|
|
||||||
help={__(
|
|
||||||
"The token has been automatically filled from the URL if available",
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="w-full"
|
|
||||||
disabled={form.formState.isSubmitting}
|
|
||||||
>
|
|
||||||
{form.formState.isSubmitting
|
|
||||||
? __("Confirming...")
|
|
||||||
: __("Confirm Email")}
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,14 +32,8 @@ function ErrorBoundary({ error: propsError }: { error?: string }) {
|
|||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: "/auth",
|
path: "/verify-magic-link",
|
||||||
Component: lazy(() => import("./pages/auth/AuthLayout")),
|
Component: lazy(() => import("./pages/auth/VerifyMagicLinkPage.tsx")),
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "verify-magic-link",
|
|
||||||
Component: lazy(() => import("./pages/auth/VerifyMagicLinkPage.tsx")),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ func (s AuthService) SendMagicLink(ctx context.Context, req *SendMagicLinkReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
magicLinkURL := req.BaseURL.
|
magicLinkURL := req.BaseURL.
|
||||||
WithPath("/auth/verify-magic-link").
|
WithPath("/verify-magic-link").
|
||||||
WithQuery("token", token).
|
WithQuery("token", token).
|
||||||
MustString()
|
MustString()
|
||||||
|
|
||||||
|
|||||||
@@ -149,8 +149,6 @@ func (s *Server) stripTrustPrefix(next http.Handler) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, prefix)
|
r.URL.Path = strings.TrimPrefix(r.URL.Path, prefix)
|
||||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/auth")
|
|
||||||
|
|
||||||
if r.URL.Path == "" {
|
if r.URL.Path == "" {
|
||||||
r.URL.Path = "/"
|
r.URL.Path = "/"
|
||||||
}
|
}
|
||||||
@@ -172,7 +170,6 @@ func (s *Server) TrustCenterHandler() http.Handler {
|
|||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
|
||||||
r.Use(compliancepage.NewSNIMiddleware(s.trustService))
|
r.Use(compliancepage.NewSNIMiddleware(s.trustService))
|
||||||
r.Use(s.stripTrustPrefix)
|
|
||||||
r.Use(func(next http.Handler) http.Handler {
|
r.Use(func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Strict-Transport-Security", "max-age=31536000; preload")
|
w.Header().Set("Strict-Transport-Security", "max-age=31536000; preload")
|
||||||
|
|||||||
Reference in New Issue
Block a user