Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/auth/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def get_current_user():
if 'user_id' not in session:
return None

if 'access_token_expires' in session:
expires_at = datetime.fromisoformat(session['access_token_expires'])
if datetime.utcnow() > expires_at:
if not refresh_access_token():
return None

return {
'user_id': session.get('user_id'),
'user_email': session.get('user_email'),
Expand Down
31 changes: 31 additions & 0 deletions frontend-vite/react-ts/src/pages/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,41 @@ import {
Upload,
Cpu,
} from 'lucide-react';
import { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import axios from 'axios';
import BarcodeWidget from '../components/BarcodeWidget';
import Navbar from '../components/Navbar';

function LandingPage() {
const [authLoading, setAuthLoading] = useState(true);
const navigate = useNavigate();
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:5000';

useEffect(() => {
const checkAuthStatus = async () => {
try {
const response = await axios.get(`${API_URL}/auth/status`, { withCredentials: true });
if (response.data.authenticated) {
navigate('/dashboard', { replace: true });
} else {
setAuthLoading(false);
}
} catch {
setAuthLoading(false);
}
};
checkAuthStatus();
}, []);

if (authLoading) {
return (
<div className="flex items-center justify-center min-h-screen bg-background">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
</div>
);
}

return (
<div className="flex min-h-screen flex-col bg-background">
<Navbar />
Expand Down
Loading