File tree Expand file tree Collapse file tree
frontend/src/containers/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,8 +147,29 @@ export class AuthController {
147147 }
148148
149149 @Post ( '/confirmPassword' )
150- confirmPassword ( @Body ( ) body : ConfirmPasswordDto ) : Promise < void > {
151- return this . authService . confirmForgotPassword ( body ) ;
150+ async confirmPassword ( @Body ( ) body : ConfirmPasswordDto ) : Promise < void > {
151+ try {
152+ await this . authService . confirmForgotPassword ( body ) ;
153+ } catch ( e ) {
154+ console . error ( 'Confirm password error:' , e ) ;
155+ // Map Cognito errors to user-friendly messages
156+ if ( e instanceof Error ) {
157+ const errName = ( e as any ) . name || '' ;
158+ if (
159+ errName === 'InvalidVerificationCodeException' ||
160+ errName === 'CodeMismatchException'
161+ ) {
162+ throw new BadRequestException ( 'Confirmation code is incorrect' ) ;
163+ }
164+ if ( errName === 'UserNotFoundException' ) {
165+ throw new BadRequestException ( 'User not found' ) ;
166+ }
167+ if ( errName === 'ExpiredCodeException' ) {
168+ throw new BadRequestException ( 'Confirmation code has expired' ) ;
169+ }
170+ }
171+ throw new BadRequestException ( e . message || 'Failed to reset password' ) ;
172+ }
152173 }
153174
154175 @Post ( '/delete' )
Original file line number Diff line number Diff line change @@ -97,18 +97,14 @@ export const ResetPasswordForm: React.FC<ResetPasswordFormProps> = ({
9797 >
9898 New Password
9999 </ Label >
100- < InputGroup
101- className = { `w-full focus-within:border-[#007B64] focus-within:ring-[2.5px] focus-within:ring-[#007B64] py-5 ${
102- error ? 'border-[#B4444D] ring-[2px] ring-[#B4444D]' : ''
103- } `}
104- >
100+ < InputGroup className = "w-full focus-within:border-[#007B64] focus-within:ring-[2.5px] focus-within:ring-[#007B64] py-5" >
105101 < InputGroupInput
106102 id = "new-password"
107103 type = { showPassword ? 'text' : 'password' }
108104 value = { newPassword }
109105 onChange = { ( e ) => setNewPassword ( e . target . value ) }
110106 placeholder = "Password"
111- className = { ` focus:ring-[#007B64] ${ error ? 'bg-[#FFFAFA]' : '' } ` }
107+ className = " focus:ring-[#007B64]"
112108 />
113109 < InputGroupAddon
114110 align = "inline-end"
You can’t perform that action at this time.
0 commit comments