955bc9a7bf
- auth/login.py: guard against missing JSON body (get_json silent=True, empty-string check) - app.py: replace infinite redirect with 404 for unknown /api/* and /setup/* paths - tools/jwtdecoder.py: add algorithms list to jwt.decode() for PyJWT 2.x compatibility - util/setup_routes.py: call reset_pool() after save_config() so pool re-initialises with new DB credentials - util/logger.py: set ERROR level on error.log handler so it no longer receives INFO/WARNING messages - LoginForm.jsx: remove dead navigate() call that was immediately overridden by window.location.href - main.jsx: remove base.css, dark.css, light.css that were already imported in App.jsx (duplicate imports) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.0 KiB
React
41 lines
1.0 KiB
React
import { useState } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import axios from '../services/api';
|
|
|
|
function LoginForm() {
|
|
const [username, setUsername] = useState('');
|
|
const [password, setPassword] = useState('');
|
|
const navigate = useNavigate();
|
|
|
|
const login = async () => {
|
|
try {
|
|
const res = await axios.post('/api/login', { username, password });
|
|
localStorage.setItem('token', res.data.token);
|
|
localStorage.setItem('role', res.data.role);
|
|
window.location.href = '/';
|
|
} catch (err) {
|
|
alert('Login fehlgeschlagen');
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="main-content">
|
|
<h2>Login</h2>
|
|
<input
|
|
value={username}
|
|
onChange={e => setUsername(e.target.value)}
|
|
placeholder="Benutzername"
|
|
/>
|
|
<input
|
|
type="password"
|
|
value={password}
|
|
onChange={e => setPassword(e.target.value)}
|
|
placeholder="Passwort"
|
|
/>
|
|
<button onClick={login}>Anmelden</button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default LoginForm;
|