diff --git a/client/src/components/input.tsx b/client/src/components/input.tsx index a45857e..47d5dbf 100644 --- a/client/src/components/input.tsx +++ b/client/src/components/input.tsx @@ -78,8 +78,8 @@ const Input = ({ type={isPassword ? (obscure ? "password" : "text") : type} placeholder={placeholder} autoComplete={autoComplete} - id={name?.toLowerCase() ?? label.toLowerCase()} - name={name?.toLowerCase() ?? label.toLowerCase()} + id={name?.toLowerCase() ?? label.toLowerCase().trim()} + name={name?.toLowerCase() ?? label.toLowerCase().trim()} disabled={disabled} required={required} maxLength={maxLength} diff --git a/client/src/constants/collections.ts b/client/src/constants/collections.ts index 27a6ab2..8acdbe3 100644 --- a/client/src/constants/collections.ts +++ b/client/src/constants/collections.ts @@ -85,7 +85,7 @@ export const SIGNIN_INPUTS = [ export const RESET_PASSWORD_INPUTS = [ { - name: "old-password", + name: "oldPassword", label: "Old Password", tooltip: "Enter your current password", placeholder: "e.g. m#P52s@ap$V", @@ -96,7 +96,7 @@ export const RESET_PASSWORD_INPUTS = [ maxLength: 128, }, { - name: "new-password", + name: "newPassword", label: "New Password", tooltip: "Create a password with at least 8 characters, including uppercase, lowercase, numbers, and special characters for security", diff --git a/client/src/lib/DTO/reset-dto.ts b/client/src/lib/DTO/reset-dto.ts index 9422bf1..1edc94e 100644 --- a/client/src/lib/DTO/reset-dto.ts +++ b/client/src/lib/DTO/reset-dto.ts @@ -1,4 +1,5 @@ export type ResetDTO = { token: string; - password: string; + oldpassword: string; + newpassword: string; }; diff --git a/client/src/lib/services/auth-service.ts b/client/src/lib/services/auth-service.ts index a5a380c..1598787 100644 --- a/client/src/lib/services/auth-service.ts +++ b/client/src/lib/services/auth-service.ts @@ -172,7 +172,8 @@ export const AuthService = { "Content-Type": "application/json", }, body: JSON.stringify({ - password: reset.password, + old_password: reset.oldpassword, + new_password: reset.newpassword, }), } ); diff --git a/client/src/pages/reset-password/_components/reset-password-form.tsx b/client/src/pages/reset-password/_components/reset-password-form.tsx index eccc1ae..cfc939b 100644 --- a/client/src/pages/reset-password/_components/reset-password-form.tsx +++ b/client/src/pages/reset-password/_components/reset-password-form.tsx @@ -55,7 +55,7 @@ const ResetPasswordForm = () => { disabled={isPending} {...r} validation={(value) => { - if (r.name === "new-password") { + if (r.name === "newPassword") { setConfirmPassword(value); } if (r.name === undefined) { diff --git a/client/src/pages/sign-in/_components/sign-in-form.tsx b/client/src/pages/sign-in/_components/sign-in-form.tsx index cecabab..3ed588d 100644 --- a/client/src/pages/sign-in/_components/sign-in-form.tsx +++ b/client/src/pages/sign-in/_components/sign-in-form.tsx @@ -6,8 +6,8 @@ import { toast } from "sonner"; import { GenericResponse } from "@/lib/classes/generic-response-class"; import { ErrorResponse } from "@/lib/classes/error-response-class"; import { AuthService } from "@/lib/services/auth-service"; -import { useAuthStore } from "@/lib/stores/auth-store"; import { SIGNIN_INPUTS } from "@/constants/collections"; +import { useAuthStore } from "@/lib/stores/auth-store"; import { SignInDTO } from "@/lib/DTO/sign-in-dto"; import { Button } from "@/components/text-button"; import { AppRoutes } from "@/constants/routes"; @@ -25,28 +25,13 @@ const SignInForm = () => { setAuthorized(true); }, onError: (error: ErrorResponse) => { - toast.error("Please verify to sign in. Didn't get the code?", { - className: "gap-x-4", - actionButtonStyle: { - background: "rgb(var(--accent))", - color: "rgb(var(--foreground))", - padding: "16px", - marginLeft: "16px", - filter: ` - drop-shadow(0 0px 25px rgb(var(--accent))) - drop-shadow(0 0px 50px rgb(var(--accent))) - `, - }, - action: { - label: "Resend", - onClick: () => navigate(AppRoutes.ResendVerify), - }, - }); - if (error.status == 403) { + toast.error("Please verify to sign in"); navigate(AppRoutes.VerifyEmail); + } else { + toast.error(error.message); + setAuthorized(false); } - setAuthorized(false); }, }); diff --git a/client/src/pages/verify-email/_components/resend-code.tsx b/client/src/pages/verify-email/_components/resend-code.tsx index 45e104a..83c8a16 100644 --- a/client/src/pages/verify-email/_components/resend-code.tsx +++ b/client/src/pages/verify-email/_components/resend-code.tsx @@ -22,16 +22,17 @@ const ResendCode = () => { return (
Didn't receive a code?