190 lines
9.2 KiB
HTML
190 lines
9.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Benutzer hinzufügen - MYP Admin</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
</head>
|
|
<body class="bg-gray-100">
|
|
<div class="min-h-screen py-8">
|
|
<div class="max-w-2xl mx-auto">
|
|
<!-- Header -->
|
|
<div class="bg-white rounded-lg shadow-md p-6 mb-6">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center space-x-3">
|
|
<i class="fas fa-user-plus text-blue-600 text-2xl"></i>
|
|
<h1 class="text-2xl font-bold text-gray-800">Neuen Benutzer hinzufügen</h1>
|
|
</div>
|
|
<a href="{{ url_for('admin_page', tab='users') }}"
|
|
class="bg-gray-500 hover:bg-gray-600 text-white px-4 py-2 rounded-lg transition-colors">
|
|
<i class="fas fa-arrow-left mr-2"></i>Zurück
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Formular -->
|
|
<div class="bg-white rounded-lg shadow-md p-6">
|
|
<form action="{{ url_for('admin_create_user_form') }}" method="POST" class="space-y-6">
|
|
<!-- CSRF Token -->
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
|
|
|
<!-- E-Mail -->
|
|
<div>
|
|
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">
|
|
<i class="fas fa-envelope mr-2"></i>E-Mail-Adresse *
|
|
</label>
|
|
<input type="email"
|
|
id="email"
|
|
name="email"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
placeholder="benutzer@beispiel.de">
|
|
</div>
|
|
|
|
<!-- Name -->
|
|
<div>
|
|
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">
|
|
<i class="fas fa-user mr-2"></i>Vollständiger Name
|
|
</label>
|
|
<input type="text"
|
|
id="name"
|
|
name="name"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
placeholder="Max Mustermann">
|
|
</div>
|
|
|
|
<!-- Passwort -->
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">
|
|
<i class="fas fa-lock mr-2"></i>Passwort *
|
|
</label>
|
|
<input type="password"
|
|
id="password"
|
|
name="password"
|
|
required
|
|
minlength="6"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
placeholder="Mindestens 6 Zeichen">
|
|
</div>
|
|
|
|
<!-- Rolle -->
|
|
<div>
|
|
<label for="role" class="block text-sm font-medium text-gray-700 mb-2">
|
|
<i class="fas fa-user-tag mr-2"></i>Benutzerrolle
|
|
</label>
|
|
<select id="role"
|
|
name="role"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
|
|
<option value="user">Benutzer</option>
|
|
<option value="admin">Administrator</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Hinweise -->
|
|
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
|
<div class="flex">
|
|
<i class="fas fa-info-circle text-blue-500 mt-0.5 mr-3"></i>
|
|
<div class="text-sm text-blue-700">
|
|
<p class="font-semibold mb-1">Hinweise:</p>
|
|
<ul class="list-disc list-inside space-y-1">
|
|
<li>Felder mit * sind Pflichtfelder</li>
|
|
<li>Das Passwort muss mindestens 6 Zeichen lang sein</li>
|
|
<li>Der Benutzername wird automatisch aus der E-Mail-Adresse generiert</li>
|
|
<li>Administratoren haben Vollzugriff auf das System</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Aktionen -->
|
|
<div class="flex space-x-3 pt-4">
|
|
<button type="submit"
|
|
class="flex-1 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-colors">
|
|
<i class="fas fa-save mr-2"></i>Benutzer erstellen
|
|
</button>
|
|
<a href="{{ url_for('admin_page', tab='users') }}"
|
|
class="flex-1 bg-gray-500 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-center transition-colors">
|
|
<i class="fas fa-times mr-2"></i>Abbrechen
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Flash Messages -->
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
<div class="fixed top-4 right-4 z-50 space-y-2">
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ 'danger' if category == 'error' else category }} bg-{{ 'red' if category == 'error' else 'green' }}-100 border border-{{ 'red' if category == 'error' else 'green' }}-400 text-{{ 'red' if category == 'error' else 'green' }}-700 px-4 py-3 rounded-lg shadow-md">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-{{ 'exclamation-triangle' if category == 'error' else 'check-circle' }} mr-2"></i>
|
|
{{ message }}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<!-- JavaScript für Form-Validierung -->
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const form = document.querySelector('form');
|
|
const emailInput = document.getElementById('email');
|
|
const passwordInput = document.getElementById('password');
|
|
|
|
// E-Mail-Validierung
|
|
emailInput.addEventListener('blur', function() {
|
|
const email = this.value;
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
|
if (email && !emailRegex.test(email)) {
|
|
this.classList.add('border-red-500');
|
|
this.classList.remove('border-gray-300');
|
|
} else {
|
|
this.classList.remove('border-red-500');
|
|
this.classList.add('border-gray-300');
|
|
}
|
|
});
|
|
|
|
// Passwort-Validierung
|
|
passwordInput.addEventListener('input', function() {
|
|
const password = this.value;
|
|
|
|
if (password.length > 0 && password.length < 6) {
|
|
this.classList.add('border-red-500');
|
|
this.classList.remove('border-gray-300');
|
|
} else {
|
|
this.classList.remove('border-red-500');
|
|
this.classList.add('border-gray-300');
|
|
}
|
|
});
|
|
|
|
// Form-Submit-Validierung
|
|
form.addEventListener('submit', function(e) {
|
|
const email = emailInput.value;
|
|
const password = passwordInput.value;
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
|
if (!email || !emailRegex.test(email)) {
|
|
e.preventDefault();
|
|
alert('Bitte geben Sie eine gültige E-Mail-Adresse ein.');
|
|
emailInput.focus();
|
|
return;
|
|
}
|
|
|
|
if (!password || password.length < 6) {
|
|
e.preventDefault();
|
|
alert('Das Passwort muss mindestens 6 Zeichen lang sein.');
|
|
passwordInput.focus();
|
|
return;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |