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

@ -92,7 +92,7 @@ function App() {
React.useEffect(() => {
const TIMEOUT_MINUTES = 15;
const WARNING_MINUTES = 2;
const WARNING_MINUTES = 2;
let timer;
let warningTimer;

View File

@ -5,9 +5,10 @@ import { RefreshCw, AlertCircle, Clock } from "lucide-react";
const logoSrc = '/assets/images/FCSCLogo.svg';
const MAX_FAILED_ATTEMPTS = 3;
const SHOW_CAPTCHA_AFTER = 2;
const LOCK_DURATION_MINUTES = 2;
const MAX_FAILED_ATTEMPTS = 3;
const SHOW_CAPTCHA_AFTER = 0;
const LOCK_DURATION_MINUTES = 2;
const Login = () => {
const navigate = useNavigate();
const location = useLocation();
@ -166,14 +167,12 @@ const Login = () => {
valid = false;
}
if (failedAttempts >= SHOW_CAPTCHA_AFTER) {
if (!userCaptcha.trim()) {
setCaptchaError('Please enter the CAPTCHA.');
valid = false;
} else if (userCaptcha !== captcha) {
setCaptchaError('Invalid CAPTCHA. Try again or refresh for a new code.');
valid = false;
}
if (!userCaptcha.trim()) {
setCaptchaError('Please enter the CAPTCHA.');
valid = false;
} else if (userCaptcha !== captcha) {
setCaptchaError('Invalid CAPTCHA. Try again or refresh for a new code.');
valid = false;
}
return valid;
@ -267,9 +266,7 @@ const Login = () => {
localStorage.setItem('failed_attempts', attempts);
setFailedAttempts(attempts);
if (attempts >= SHOW_CAPTCHA_AFTER) {
refreshCaptcha();
}
refreshCaptcha();
if (attempts >= MAX_FAILED_ATTEMPTS) {
const lockUntil = Date.now() + LOCK_DURATION_MINUTES * 60 * 1000;
@ -337,7 +334,7 @@ const Login = () => {
</div>
<form onSubmit={submit} className="px-7 py-8 space-y-4">
{isLocked && remainingTime > 0 && (
{isLocked && remainingTime > 0 && (
<div className="bg-red-50 border-l-4 border-red-500 p-4 rounded">
<div className="flex items-start gap-3">
<Clock className="h-5 w-5 text-red-500 mt-0.5 flex-shrink-0" />
@ -435,8 +432,7 @@ const Login = () => {
{passwordError && <p className="text-xs text-red-600 mt-1">{passwordError}</p>}
</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">
CAPTCHA Verification <span className="text-red-500">*</span>
</label>
@ -483,7 +479,7 @@ const Login = () => {
/>
{captchaError && <p className="text-xs text-red-600 mt-1">{captchaError}</p>}
</div>
)}
<div className="flex items-center justify-between text-sm">
<label className="inline-flex items-center gap-2 cursor-pointer">
@ -512,7 +508,7 @@ const Login = () => {
disabled={
loading ||
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 ${
isLocked