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