diff --git a/src/components/Instructor/ForgotPassword.jsx b/src/components/Instructor/ForgotPassword.jsx
index 53ff047..d488510 100644
--- a/src/components/Instructor/ForgotPassword.jsx
+++ b/src/components/Instructor/ForgotPassword.jsx
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
-import Logo1 from "../../assets/img/Dct-Logo.png";
+import Logo1 from "../../assets/img/TaskSphereLogo.png";
import Swal from "sweetalert2";
import { showOTP, fetchAdminEmail } from "../../assets/scripts/forgotPassword";
@@ -25,7 +25,7 @@ const ForgotPassword = () => {
icon: "warning",
title: "Enter your email",
text: "Please provide the email you registered with.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
return;
}
@@ -40,7 +40,7 @@ const ForgotPassword = () => {
icon: "error",
title: "Not an admin email",
text: "Only admin accounts can reset a password here.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
return;
}
@@ -57,7 +57,7 @@ const ForgotPassword = () => {
icon: "success",
title: "OTP sent",
html: `We've sent a 6-digit code to ${entered} .`,
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
allowOutsideClick: false,
allowEscapeKey: false,
});
@@ -68,7 +68,6 @@ const ForgotPassword = () => {
expectedOtp: otp,
onConfirm: async (code, { expected }) => {
if (String(code) === String(expected)) {
- //alert("success");
navigate("/NewPassword", { state: { email: entered } });
return true; // ✅ close the Swal
}
@@ -87,7 +86,7 @@ const ForgotPassword = () => {
icon: "error",
title: "Something went wrong",
text: err?.message || "Please try again in a moment.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
} finally {
setSending(false);
@@ -95,18 +94,19 @@ const ForgotPassword = () => {
};
return (
-
-
+
+
-
+
Forgot Password?
- No worries! To reset your password, we’ll send a one-time password
+ No worries! To reset your password, we'll send a one-time password
(OTP) to your registered email address. Please check your inbox and
follow the instructions to continue.
@@ -115,7 +115,7 @@ const ForgotPassword = () => {
Email
@@ -125,17 +125,17 @@ const ForgotPassword = () => {
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="admin1@gmail.com"
- className="w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-[#3B0304] focus:outline-none"
+ className="w-full p-3 bg-white border border-gray-300 rounded-md focus:ring-2 focus:ring-[#611A11] focus:border-[#611A11] focus:outline-none"
/>
{sending ? "Sending OTP..." : "Reset Password"}
@@ -146,4 +146,4 @@ const ForgotPassword = () => {
);
};
-export default ForgotPassword;
+export default ForgotPassword;
\ No newline at end of file
diff --git a/src/components/Instructor/newPassword.jsx b/src/components/Instructor/newPassword.jsx
index 7d2c1ca..e6f9246 100644
--- a/src/components/Instructor/newPassword.jsx
+++ b/src/components/Instructor/newPassword.jsx
@@ -1,14 +1,13 @@
import React, { useMemo, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import Swal from "sweetalert2";
-import Logo1 from "../../assets/img/Dct-Logo.png";
+import Logo1 from "../../assets/img/TaskSphereLogo.png";
import { updateUserPassword } from "../../assets/scripts/forgotPassword";
const NewPassword = () => {
const location = useLocation();
const navigate = useNavigate();
- // Email comes from the previous step via router state
const verifiedEmail = useMemo(
() => location.state?.email || "",
[location.state]
@@ -19,6 +18,55 @@ const NewPassword = () => {
const [newPw, setNewPw] = useState("");
const [confirmPw, setConfirmPw] = useState("");
const [saving, setSaving] = useState(false);
+ const [passwordError, setPasswordError] = useState("");
+
+ // Password validation function
+ const validatePassword = (pass) => {
+ const errors = [];
+
+ if (/\s/.test(pass)) {
+ errors.push("Password cannot contain spaces");
+ }
+
+ if (pass.length < 8) {
+ errors.push("Password must be at least 8 characters");
+ }
+
+ if (!/[A-Z]/.test(pass)) {
+ errors.push("Password must contain at least one uppercase letter");
+ }
+
+ if (!/[a-z]/.test(pass)) {
+ errors.push("Password must contain at least one lowercase letter");
+ }
+
+ if (!/[0-9]/.test(pass)) {
+ errors.push("Password must contain at least one number");
+ }
+
+ if (!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(pass)) {
+ errors.push("Password must contain at least one special character");
+ }
+
+ return errors;
+ };
+
+ // Handle password change with validation
+ const handlePasswordChange = (e) => {
+ const newPassword = e.target.value;
+ setNewPw(newPassword);
+
+ if (newPassword) {
+ const errors = validatePassword(newPassword);
+ if (errors.length > 0) {
+ setPasswordError(errors[0]);
+ } else {
+ setPasswordError("");
+ }
+ } else {
+ setPasswordError("");
+ }
+ };
const handleConfirm = async () => {
if (!verifiedEmail) {
@@ -26,35 +74,40 @@ const NewPassword = () => {
icon: "error",
title: "Missing email",
text: "This page needs the verified email from the previous step.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
- navigate("/forgot-password"); // send them back to start the flow correctly
+ navigate("/forgot-password");
return;
}
+
if (!newPw || !confirmPw) {
Swal.fire({
icon: "warning",
title: "Enter both fields",
text: "Please enter and confirm your new password.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
return;
}
- if (newPw !== confirmPw) {
+
+ // Validate password format
+ const passwordErrors = validatePassword(newPw);
+ if (passwordErrors.length > 0) {
Swal.fire({
icon: "error",
- title: "Passwords don’t match",
- text: "Please make sure both passwords are identical.",
- confirmButtonColor: "#3B0304",
+ title: "Invalid Password Format",
+ html: passwordErrors.map(err => `• ${err}`).join(' '),
+ confirmButtonColor: "#611A11",
});
return;
}
- if (newPw.length < 8) {
+
+ if (newPw !== confirmPw) {
Swal.fire({
- icon: "warning",
- title: "Weak password",
- text: "Use at least 8 characters.",
- confirmButtonColor: "#3B0304",
+ icon: "error",
+ title: "Passwords don't match",
+ text: "Please make sure both passwords are identical.",
+ confirmButtonColor: "#611A11",
});
return;
}
@@ -66,7 +119,7 @@ const NewPassword = () => {
icon: "success",
title: "Password updated",
text: "Your password has been changed successfully.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
navigate("/login");
} catch (e) {
@@ -75,7 +128,7 @@ const NewPassword = () => {
icon: "error",
title: "Update failed",
text: e?.message || "Please try again.",
- confirmButtonColor: "#3B0304",
+ confirmButtonColor: "#611A11",
});
} finally {
setSaving(false);
@@ -83,57 +136,57 @@ const NewPassword = () => {
};
return (
-
-
+
+
-
+
TaskSphere IT
-
+
Set your New Password