This commit is contained in:
Atakan
2025-11-28 15:50:32 +03:00
parent 3e565663f7
commit 329b3df928
4 changed files with 80 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { motion } from 'framer-motion';
import { GitBranch, Video, Mail, Cloud, Puzzle, ArrowRight, ArrowLeft, LogOut } from 'lucide-react';
import { Link, useNavigate } from 'react-router-dom';
@@ -23,17 +23,31 @@ const cardVariants = {
export default function Portal() {
const navigate = useNavigate();
// Kullanıcı adını state'ten veya storage'dan alalım
const [user, setUser] = useState({ name: "Atakan" });
// Sayfa yüklendiğinde güvenlik kontrolü yap
useEffect(() => {
const isAuth = sessionStorage.getItem('isAuthenticated');
if (isAuth !== 'true') {
navigate('/'); // Giriş yoksa ana sayfaya at
// Backend'den aldığımız token'ı kontrol ediyoruz
const token = sessionStorage.getItem('authToken');
const userData = sessionStorage.getItem('user');
if (!token) {
navigate('/'); // Token yoksa ana sayfaya at
}
if (userData) {
try {
setUser(JSON.parse(userData));
} catch (e) {
// JSON parse hatası olursa varsayılan kalır
}
}
}, [navigate]);
const handleLogout = () => {
sessionStorage.removeItem('isAuthenticated');
sessionStorage.removeItem('authToken');
sessionStorage.removeItem('user');
navigate('/');
};
@@ -54,7 +68,8 @@ export default function Portal() {
<motion.div initial={{ opacity: 0, y: -20 }} animate={{ opacity: 1, y: 0 }} className="text-center mb-12">
<h1 className="text-4xl md:text-5xl font-bold mb-2 text-white">Yönetim Portalı</h1>
<p className="text-slate-400">Hoş geldin, Atakan. Servisler aktif.</p>
{/* Kullanıcı adını dinamik gösterelim */}
<p className="text-slate-400">Hoş geldin, {user.username || user.name || "Admin"}. Servisler aktif.</p>
</motion.div>
<motion.div variants={containerVariants} initial="hidden" animate="visible" className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">