From 922fa45fa77ef90d5f7e8dbf5cf50cf1219b227e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 5 Feb 2024 22:47:07 +0800 Subject: [PATCH] :bug: Fix redirect missing search parameters --- pkg/server/oauth_api.go | 4 ++++ pkg/view/src/layouts/RootLayout.tsx | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/server/oauth_api.go b/pkg/server/oauth_api.go index 898cbb9..24007f7 100644 --- a/pkg/server/oauth_api.go +++ b/pkg/server/oauth_api.go @@ -15,6 +15,10 @@ func preConnect(c *fiber.Ctx) error { id := c.Query("client_id") redirect := c.Query("redirect_uri") + if len(id) <= 0 || len(redirect) <= 0 { + return fiber.NewError(fiber.StatusBadRequest, "invalid request, missing query parameters") + } + var client models.ThirdClient if err := database.C.Where(&models.ThirdClient{Alias: id}).First(&client).Error; err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) diff --git a/pkg/view/src/layouts/RootLayout.tsx b/pkg/view/src/layouts/RootLayout.tsx index 0d8ab15..a9c8c28 100644 --- a/pkg/view/src/layouts/RootLayout.tsx +++ b/pkg/view/src/layouts/RootLayout.tsx @@ -2,7 +2,7 @@ import Navbar from "./shared/Navbar.tsx"; import { readProfiles, useUserinfo } from "../stores/userinfo.tsx"; import { createEffect, createSignal, Show } from "solid-js"; import { readWellKnown } from "../stores/wellKnown.tsx"; -import { BeforeLeaveEventArgs, useBeforeLeave, useLocation, useNavigate } from "@solidjs/router"; +import { BeforeLeaveEventArgs, useLocation, useNavigate } from "@solidjs/router"; export default function RootLayout(props: any) { const [ready, setReady] = createSignal(false); @@ -16,9 +16,9 @@ export default function RootLayout(props: any) { createEffect(() => { if (ready()) { - keepGate(location.pathname); + keepGate(location.pathname + location.search); } - }, [ready, userinfo]); + }, [ready, userinfo, location]); function keepGate(path: string, e?: BeforeLeaveEventArgs) { const pathname = path.split("?")[0]; @@ -30,8 +30,6 @@ export default function RootLayout(props: any) { } } - useBeforeLeave((e: BeforeLeaveEventArgs) => keepGate(e.to.toString(), e)); - return (