login page again captcha updated

This commit is contained in:
Senthamilselvi 2025-11-05 10:43:31 +05:30
parent 0e56ed7a78
commit cf07aaea22
2 changed files with 16 additions and 20 deletions

View File

@ -6,8 +6,9 @@ import { RefreshCw, AlertCircle, Clock } from "lucide-react";
const logoSrc = '/assets/images/FCSCLogo.svg'; const logoSrc = '/assets/images/FCSCLogo.svg';
const MAX_FAILED_ATTEMPTS = 3; const MAX_FAILED_ATTEMPTS = 3;
const SHOW_CAPTCHA_AFTER = 2; const SHOW_CAPTCHA_AFTER = 0;
const LOCK_DURATION_MINUTES = 2; const LOCK_DURATION_MINUTES = 2;
const Login = () => { const Login = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation(); const location = useLocation();
@ -166,7 +167,6 @@ const Login = () => {
valid = false; valid = false;
} }
if (failedAttempts >= SHOW_CAPTCHA_AFTER) {
if (!userCaptcha.trim()) { if (!userCaptcha.trim()) {
setCaptchaError('Please enter the CAPTCHA.'); setCaptchaError('Please enter the CAPTCHA.');
valid = false; valid = false;
@ -174,7 +174,6 @@ const Login = () => {
setCaptchaError('Invalid CAPTCHA. Try again or refresh for a new code.'); setCaptchaError('Invalid CAPTCHA. Try again or refresh for a new code.');
valid = false; valid = false;
} }
}
return valid; return valid;
}; };
@ -267,9 +266,7 @@ const Login = () => {
localStorage.setItem('failed_attempts', attempts); localStorage.setItem('failed_attempts', attempts);
setFailedAttempts(attempts); setFailedAttempts(attempts);
if (attempts >= SHOW_CAPTCHA_AFTER) {
refreshCaptcha(); refreshCaptcha();
}
if (attempts >= MAX_FAILED_ATTEMPTS) { if (attempts >= MAX_FAILED_ATTEMPTS) {
const lockUntil = Date.now() + LOCK_DURATION_MINUTES * 60 * 1000; const lockUntil = Date.now() + LOCK_DURATION_MINUTES * 60 * 1000;
@ -435,7 +432,6 @@ const Login = () => {
{passwordError && <p className="text-xs text-red-600 mt-1">{passwordError}</p>} {passwordError && <p className="text-xs text-red-600 mt-1">{passwordError}</p>}
</div> </div>
{failedAttempts >= SHOW_CAPTCHA_AFTER && (
<div className="mt-4"> <div className="mt-4">
<label className="block text-sm font-medium text-gray-700 mb-1"> <label className="block text-sm font-medium text-gray-700 mb-1">
CAPTCHA Verification <span className="text-red-500">*</span> CAPTCHA Verification <span className="text-red-500">*</span>
@ -483,7 +479,7 @@ const Login = () => {
/> />
{captchaError && <p className="text-xs text-red-600 mt-1">{captchaError}</p>} {captchaError && <p className="text-xs text-red-600 mt-1">{captchaError}</p>}
</div> </div>
)}
<div className="flex items-center justify-between text-sm"> <div className="flex items-center justify-between text-sm">
<label className="inline-flex items-center gap-2 cursor-pointer"> <label className="inline-flex items-center gap-2 cursor-pointer">
@ -512,7 +508,7 @@ const Login = () => {
disabled={ disabled={
loading || loading ||
isLocked || isLocked ||
(failedAttempts >= SHOW_CAPTCHA_AFTER && !userCaptcha.trim()) !userCaptcha.trim()
} }
className={`inline-flex items-center justify-center w-full h-12 rounded-lg text-white font-medium ${ className={`inline-flex items-center justify-center w-full h-12 rounded-lg text-white font-medium ${
isLocked isLocked