-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement session management with JSON file; add dashboard component …
…and styles
- Loading branch information
1 parent
e5a8679
commit e127e19
Showing
6 changed files
with
244 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ __pycache__ | |
cas.egg-info | ||
dist | ||
CLI/cas/session_details.json | ||
CLI/cas/session.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import styles from "../page.module.css"; | ||
|
||
import Dashboard from "../../components/dashboard/dashboard" | ||
|
||
export default function Home() { | ||
return ( | ||
<div className={styles.page}> | ||
<main className={styles.main}> | ||
<Dashboard /> | ||
</main> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use client'; | ||
|
||
import React, { useState, useEffect } from 'react'; | ||
import { onAuthStateChanged, signOut } from 'firebase/auth'; | ||
import { useRouter } from 'next/navigation'; | ||
import { auth } from '../../../shared/firebase'; | ||
import Logout from '../auth/logout/logout'; | ||
import styles from './dashboard.module.css'; | ||
|
||
const Dashboard = () => { | ||
const [user, setUser] = useState(null); | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
// Listen to authentication state changes | ||
const unsubscribe = onAuthStateChanged(auth, (currentUser) => { | ||
if (currentUser) { | ||
setUser(currentUser); | ||
} else { | ||
router.push('/auth'); // Redirect to auth page if no user is logged in | ||
} | ||
}); | ||
|
||
return () => unsubscribe(); | ||
}, [router]); | ||
|
||
const handleLogout = async () => { | ||
try { | ||
await signOut(auth); | ||
setUser(null); | ||
router.push('/auth'); // Redirect to auth page after logout | ||
} catch (error) { | ||
console.error('Logout failed:', error.message); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={styles.dashboardContainer}> | ||
{user ? ( | ||
<div> | ||
<h2 className={styles.dashboardHeader}>Welcome to your Dashboard, {user.email}</h2> | ||
<div className={styles.dashboardContent}> | ||
<p className={styles.dashboardMessage}>Here you can manage your account, settings, and more.</p> | ||
<br /> | ||
<Logout onLogout={handleLogout} /> | ||
</div> | ||
</div> | ||
) : ( | ||
<div> | ||
<h2 className={styles.dashboardHeader}>Loading...</h2> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
.authContainer { | ||
|
||
--primary-bg: #0d1117; | ||
--primary-accent: #1f6feb; | ||
--secondary-accent: #58a6ff; | ||
--text-primary: #c9d1d9; | ||
--text-secondary: #8b949e; | ||
--error-color: #ff7b72; | ||
--success-color: #56d364; | ||
--button-hover: #30363d; | ||
|
||
|
||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
margin: 20px auto; | ||
padding: 20px; | ||
max-width: 95%; | ||
width: 400px; | ||
background-color: var(--primary-bg); | ||
border-radius: 12px; | ||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); | ||
animation: fadeIn 0.5s ease-in-out; | ||
} | ||
|
||
.authHeader { | ||
font-size: 24px; | ||
font-weight: 600; | ||
color: var(--text-primary); | ||
margin-bottom: 20px; | ||
text-align: center; | ||
} | ||
|
||
.authMessage { | ||
font-size: 16px; | ||
color: var(--text-secondary); | ||
margin-top: 15px; | ||
text-align: center; | ||
} | ||
|
||
.success { | ||
color: var(--success-color); | ||
} | ||
|
||
.error { | ||
color: var(--error-color); | ||
} | ||
|
||
.authForm { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 15px; | ||
width: 100%; | ||
} | ||
|
||
.authForm label { | ||
font-size: 14px; | ||
color: var(--text-secondary); | ||
} | ||
|
||
.authForm input { | ||
padding: 10px; | ||
font-size: 14px; | ||
color: var(--text-primary); | ||
background-color: #161b22; | ||
border: 1px solid var(--primary-accent); | ||
border-radius: 6px; | ||
outline: none; | ||
transition: all 0.3s ease-in-out; | ||
} | ||
|
||
.authForm input:focus { | ||
border-color: var(--secondary-accent); | ||
box-shadow: 0 0 4px var(--secondary-accent); | ||
} | ||
|
||
.authForm button { | ||
padding: 12px 0; | ||
font-size: 14px; | ||
font-weight: 600; | ||
color: #fff; | ||
background-color: var(--primary-accent); | ||
border: none; | ||
border-radius: 6px; | ||
cursor: pointer; | ||
transition: all 0.3s ease-in-out; | ||
} | ||
|
||
.authForm button:hover { | ||
background-color: var(--secondary-accent); | ||
} | ||
|
||
.toggleContainer { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
margin-bottom: 15px; | ||
} | ||
|
||
.button { | ||
flex: 1; | ||
padding: 10px 0; | ||
margin: 0 5px; | ||
font-size: 14px; | ||
font-weight: 600; | ||
text-align: center; | ||
border: 1px solid var(--primary-accent); | ||
border-radius: 6px; | ||
background: transparent; | ||
color: var(--primary-accent); | ||
cursor: pointer; | ||
transition: all 0.3s ease-in-out; | ||
} | ||
|
||
.button:hover { | ||
background-color: var(--button-hover); | ||
color: var(--secondary-accent); | ||
} | ||
|
||
.active { | ||
background-color: var(--primary-accent); | ||
color: #fff; | ||
border: none; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.authContainer { | ||
width: 100%; | ||
padding: 15px; | ||
} | ||
|
||
.authHeader { | ||
font-size: 20px; | ||
} | ||
|
||
.button { | ||
font-size: 13px; | ||
} | ||
} | ||
|
||
/* Animations */ | ||
@keyframes fadeIn { | ||
from { | ||
opacity: 0; | ||
transform: translateY(-20px); | ||
} | ||
to { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
} | ||
|