fix: LoginPage accessibility (labels, alert), open-redirect guard

This commit is contained in:
2026-05-07 20:14:06 +03:00
parent b52e3685ac
commit 5628f45c71
+8 -4
View File
@@ -11,7 +11,8 @@ const LoginPage = () => {
const { login } = useAuth();
const navigate = useNavigate();
const location = useLocation();
const from = location.state?.from?.pathname || '/admin/kanban';
const rawFrom = location.state?.from?.pathname || '/admin/kanban';
const from = rawFrom.startsWith('/admin') ? rawFrom : '/admin/kanban';
const handleSubmit = async (e) => {
e.preventDefault();
@@ -22,6 +23,7 @@ const LoginPage = () => {
setError('Неверный email или пароль');
setSubmitting(false);
} else {
setSubmitting(false);
navigate(from, { replace: true });
}
};
@@ -64,8 +66,9 @@ const LoginPage = () => {
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: '20px' }}>
<div>
<label style={labelStyle}>Email</label>
<label htmlFor="login-email" style={labelStyle}>Email</label>
<input
id="login-email"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
@@ -77,8 +80,9 @@ const LoginPage = () => {
</div>
<div>
<label style={labelStyle}>Пароль</label>
<label htmlFor="login-password" style={labelStyle}>Пароль</label>
<input
id="login-password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
@@ -90,7 +94,7 @@ const LoginPage = () => {
</div>
{error && (
<p style={{ color: '#ef4444', fontSize: '0.9rem', margin: 0 }}>{error}</p>
<p role="alert" style={{ color: '#ef4444', fontSize: '0.9rem', margin: 0 }}>{error}</p>
)}
<button