Implement OAuth login with Authentik integration, update user management, and enhance team functionalities

- Added OAuth login functionality using Authentik, allowing users to log in via OpenID.
- Updated user registration and login processes to handle OAuth users.
- Enhanced team management features, including joining and leaving teams, and displaying user-specific team information.
- Improved error handling and user feedback for team actions.
- Added new database migrations for OAuth-related fields in the users table.
- Updated templates to reflect changes in user authentication and team management.
- Refactored dashboard and leaderboard views to include user context and team memberships.
This commit is contained in:
Christian Krakau-Louis
2025-04-14 05:35:51 +02:00
parent fa41b24eac
commit 690065f788
15 changed files with 938 additions and 139 deletions
+9 -2
View File
@@ -9,7 +9,7 @@ from sqlalchemy import func, desc
from datetime import datetime, timedelta
from ..db import SessionLocal
from ..models import Team, TeamMembership, QRCode
from ..models import Team, TeamMembership, QRCode, User
from ..templates_config import templates
router = APIRouter()
@@ -29,6 +29,12 @@ async def show_leaderboard(
):
"""Show the leaderboard with team rankings."""
# Get user from session for navbar
user = None
user_id = request.session.get("user_id")
if user_id:
user = db.query(User).get(user_id)
# Define cutoff date based on timeframe
cutoff_date = None
if timeframe == "week":
@@ -81,6 +87,7 @@ async def show_leaderboard(
"teams": ranked_teams,
"top_teams": top_teams,
"timeframe": timeframe,
"time_label": time_label
"time_label": time_label,
"user": user # Add user to the context
}
)