feat: JWT-Authentifizierung in SettingModal implementiert und Modal-Stabilität verbessert

- JWT-Token-Erstellung und -Speicherung für sichere Admin-Authentifizierung in SettingModal hinzugefügt.
- Stabilitätsprobleme des Modals behoben.
- Funktionalität des Modals und des Tokens überprüft, um eine reibungslose Benutzererfahrung sicherzustellen.
This commit is contained in:
ISA
2024-11-14 13:48:04 +01:00
parent 172134a16f
commit c0ffbbcf38
5 changed files with 279 additions and 355 deletions

View File

@@ -1,4 +1,5 @@
"use client"; // components/Header.jsx
// components/Header.jsx
"use client";
import React, { useState } from "react";
import Image from "next/image";
import { useRouter } from "next/router";
@@ -15,13 +16,6 @@ function Header() {
const handleCloseSettingsModal = () => setShowSettingsModal(false);
const handleLogout = () => (window.location.href = "/offline.html");
// Funktion zur Weiterleitung zur Login-Seite abhängig von der Umgebung
const handleAdminLogin = () => {
const loginPath =
process.env.NODE_ENV === "production" ? "/login.html" : "/login";
router.push(loginPath);
};
return (
<header className="bg-gray-300 flex justify-between items-center w-full h-28 relative text-black">
<div className="absolute left-32 top-32 transform -translate-y-1/2">
@@ -52,14 +46,6 @@ function Header() {
</button>
</div>
<div className="flex items-center justify-end w-full space-x-2">
<button
onClick={handleAdminLogin}
title="Als Admin anmelden"
className="bg-littwin-blue text-white px-4 py-2 rounded flex items-center"
>
<i className="bi bi-person-circle mr-2"></i>
</button>
<button
onClick={handleLogout}
className="bg-littwin-blue text-white px-4 py-2 rounded"