The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix reset PasswordToken (#6366)
Charles Bochetc69d665114e1
diff --git a/packages/twenty-front/project.json b/packages/twenty-front/project.jsonindex 4c427109b05..636fd29af6a 100644--- a/packages/twenty-front/project.json+++ b/packages/twenty-front/project.json@@ -61,7 +61,7 @@"test": {},"storybook:build": {"options": {- "env": { "NODE_OPTIONS": "--max_old_space_size=5000" }+ "env": { "NODE_OPTIONS": "--max_old_space_size=6000" }}},"storybook:serve:dev": {diff --git a/packages/twenty-front/src/effect-components/PageChangeEffect.tsx b/packages/twenty-front/src/effect-components/PageChangeEffect.tsxindex a49b3c29bd1..78578016605 100644--- a/packages/twenty-front/src/effect-components/PageChangeEffect.tsx+++ b/packages/twenty-front/src/effect-components/PageChangeEffect.tsx@@ -165,7 +165,9 @@ export const PageChangeEffect = () => {useEffect(() => {if (isCaptchaScriptLoaded &&- isMatchingLocation(AppPath.SignInUp || AppPath.Invite)+ (isMatchingLocation(AppPath.SignInUp) ||+ isMatchingLocation(AppPath.Invite) ||+ isMatchingLocation(AppPath.ResetPassword))) {requestFreshCaptchaToken();}diff --git a/packages/twenty-front/src/pages/auth/PasswordReset.tsx b/packages/twenty-front/src/pages/auth/PasswordReset.tsxindex f40e98c3e81..79ea7074021 100644--- a/packages/twenty-front/src/pages/auth/PasswordReset.tsx+++ b/packages/twenty-front/src/pages/auth/PasswordReset.tsx@@ -1,12 +1,12 @@-import { useState } from 'react';-import { Controller, useForm } from 'react-hook-form';-import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';-import { useNavigate, useParams } from 'react-router-dom';import { useTheme } from '@emotion/react';import styled from '@emotion/styled';import { zodResolver } from '@hookform/resolvers/zod';import { isNonEmptyString } from '@sniptt/guards';import { motion } from 'framer-motion';+import { useState } from 'react';+import { Controller, useForm } from 'react-hook-form';+import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';+import { useNavigate, useParams } from 'react-router-dom';import { useSetRecoilState } from 'recoil';import { z } from 'zod';@@ -15,6 +15,7 @@ import { Title } from '@/auth/components/Title';import { useAuth } from '@/auth/hooks/useAuth';import { useIsLogged } from '@/auth/hooks/useIsLogged';import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex';+import { useReadCaptchaToken } from '@/captcha/hooks/useReadCaptchaToken';import { AppPath } from '@/types/AppPath';import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';@@ -118,6 +119,7 @@ export const PasswordReset = () => {useUpdatePasswordViaResetTokenMutation();const { signInWithCredentials } = useAuth();+ const { readCaptchaToken } = useReadCaptchaToken();const onSubmit = async (formData: Form) => {try {@@ -143,7 +145,9 @@ export const PasswordReset = () => {return;}- await signInWithCredentials(email || '', formData.newPassword);+ const token = await readCaptchaToken();++ await signInWithCredentials(email || '', formData.newPassword, token);navigate(AppPath.Index);} catch (err) {logError(err);diff --git a/packages/twenty-server/src/engine/core-modules/auth/dto/password-reset-token.input.ts b/packages/twenty-server/src/engine/core-modules/auth/dto/password-reset-token.input.tsdeleted file mode 100644index 5120af2942c..00000000000--- a/packages/twenty-server/src/engine/core-modules/auth/dto/password-reset-token.input.ts+++ /dev/null@@ -1,11 +0,0 @@-import { ArgsType, Field } from '@nestjs/graphql';--import { IsEmail, IsNotEmpty } from 'class-validator';--@ArgsType()-export class PasswordResetTokenInput {- @Field(() => String)- @IsNotEmpty()- @IsEmail()- email: string;-}