import React, { useState } from 'react'; import axios from 'axios'; import { motion } from 'framer-motion'; import { FaLock, FaSpinner } from 'react-icons/fa'; const LoginScreen = ({ onAuthenticated }) => { const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleSubmit = async (e) => { e.preventDefault(); if (!password.trim()) { setError('Please enter a password'); return; } setLoading(true); setError(null); try { const response = await axios.post('/api/auth/verify', { password }); if (response.data.authenticated) { // Store auth state in sessionStorage (cleared when browser closes) sessionStorage.setItem('auth_verified', 'true'); onAuthenticated(); } } catch (err) { if (err.response?.status === 401) { setError('Invalid password. Please try again.'); } else { setError('Authentication failed. Please try again.'); } console.error('Auth error:', err); } finally { setLoading(false); } }; return (
Enter password to access
Protected application. Contact administrator for access.