Login mit Admin Admin login bis zum Dashboard
erfolgreich
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// src/components/LoginForm.jsx
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import axios from '../services/api';
|
||||
@@ -10,7 +9,7 @@ function LoginForm() {
|
||||
|
||||
const login = async () => {
|
||||
try {
|
||||
const res = await axios.post('/login', { username, password });
|
||||
const res = await axios.post('/login', { username, password }); // ruft POST /api/login auf
|
||||
localStorage.setItem('token', res.data.token);
|
||||
localStorage.setItem('role', res.data.role);
|
||||
navigate('/');
|
||||
@@ -22,8 +21,17 @@ function LoginForm() {
|
||||
return (
|
||||
<div>
|
||||
<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" />
|
||||
<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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user