login page again captcha updated
This commit is contained in:
parent
0e56ed7a78
commit
cf07aaea22
@ -92,7 +92,7 @@ function App() {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const TIMEOUT_MINUTES = 15;
|
const TIMEOUT_MINUTES = 15;
|
||||||
const WARNING_MINUTES = 2;
|
const WARNING_MINUTES = 2;
|
||||||
|
|
||||||
let timer;
|
let timer;
|
||||||
let warningTimer;
|
let warningTimer;
|
||||||
|
|||||||
@ -5,9 +5,10 @@ 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,14 +167,12 @@ 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;
|
} else if (userCaptcha !== captcha) {
|
||||||
} else if (userCaptcha !== captcha) {
|
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;
|
||||||
@ -337,7 +334,7 @@ const Login = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form onSubmit={submit} className="px-7 py-8 space-y-4">
|
<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="bg-red-50 border-l-4 border-red-500 p-4 rounded">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<Clock className="h-5 w-5 text-red-500 mt-0.5 flex-shrink-0" />
|
<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>}
|
{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>
|
||||||
</label>
|
</label>
|
||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user