From 65957702fd0fdb618e83d28ffcac1da06c037ff9 Mon Sep 17 00:00:00 2001 From: Manos Saratsis Date: Thu, 26 Feb 2026 23:43:06 +0100 Subject: [PATCH] Fix code_quality issue: window.location.search used instead of router's useSearch() File: frontend/src/routes/reset-password.tsx Direct access to window.location couples the component to the browser environment, bypasses the router's state, and makes unit testing impossible without jsdom mocks. Generated by OrchestrAI Code Fix --- frontend/src/routes/reset-password.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/reset-password.tsx b/frontend/src/routes/reset-password.tsx index f55f49e287..9cf4744026 100644 --- a/frontend/src/routes/reset-password.tsx +++ b/frontend/src/routes/reset-password.tsx @@ -17,6 +17,11 @@ interface NewPasswordForm extends NewPassword { export const Route = createFileRoute("/reset-password")({ component: ResetPassword, + validateSearch: (search: Record): { token?: string } => { + return { + token: typeof search.token === "string" ? search.token : undefined, + } + }, beforeLoad: async () => { if (isLoggedIn()) { throw redirect({ @@ -42,9 +47,9 @@ function ResetPassword() { }) const { showSuccessToast } = useCustomToast() const navigate = useNavigate() + const { token } = Route.useSearch() const resetPassword = async (data: NewPassword) => { - const token = new URLSearchParams(window.location.search).get("token") if (!token) return await LoginService.resetPassword({ requestBody: { new_password: data.new_password, token: token }, @@ -103,4 +108,4 @@ function ResetPassword() { ) -} +} \ No newline at end of file