Merge pull request 'fix: added validation for update password' (#81) from change-password-validation into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-mobile-ui/pulls/81 Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
commit
59ddb35bb2
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue