From 08cc9adf1a0c7adab848e7041f3f4db78fdc9cef Mon Sep 17 00:00:00 2001 From: Urvish Date: Mon, 26 Oct 2026 11:54:27 +0530 Subject: [PATCH] fix: added validation for update password --- src/app/profile/change-password.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/profile/change-password.tsx b/src/app/profile/change-password.tsx index 806b41e..c4b5772 100644 --- a/src/app/profile/change-password.tsx +++ b/src/app/profile/change-password.tsx @@ -42,6 +42,9 @@ export default function ChangePasswordScreen() { if (!newPassword) { setNewError("New password is required"); hasError = true; + } else if (currentPassword && newPassword === currentPassword) { + setNewError("New password cannot be the same as current password"); + hasError = true; } else if (newPassword.length < 8) { setNewError("New password must be at least 8 characters"); hasError = true; @@ -89,7 +92,14 @@ export default function ChangePasswordScreen() { const errMsg = err?.response?.data?.detail || "Failed to update password. Please check your current password."; - setCurrentError(errMsg); + if ( + typeof errMsg === "string" && + errMsg.toLowerCase().includes("same") + ) { + setNewError(errMsg); + } else { + setCurrentError(errMsg); + } if (Platform.OS === "web") { window.alert(errMsg); } else {