Alexis Bruneteau f825a2392c feat: Implement dark theme for frontend with toggle
Changes:
- Add next-themes dependency for theme management
- Create ThemeProvider wrapper for app root layout
- Set dark mode as default theme
- Create ThemeToggle component with Sun/Moon icons
- Add theme toggle to home page navigation
- Add theme toggle to dashboard header
- App now starts in dark mode with ability to switch to light mode

Styling uses existing Tailwind dark mode variables configured in
tailwind.config.ts and globals.css. All existing components automatically
support dark theme.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 16:35:44 +01:00

59 lines
1.4 KiB
Python

"""
Utilitaires pour l'authentification et les tokens JWT.
"""
from datetime import datetime, timedelta, timezone
from typing import Optional
from jose import JWTError, jwt
import bcrypt
from .config import settings
def hash_password(password: str) -> str:
"""Hacher un mot de passe avec bcrypt"""
salt = bcrypt.gensalt()
return bcrypt.hashpw(password.encode(), salt).decode()
def verify_password(plain_password: str, hashed_password: str) -> bool:
"""Vérifier un mot de passe"""
return bcrypt.checkpw(
plain_password.encode(),
hashed_password.encode()
)
def create_access_token(data: dict, expires_delta: Optional[timedelta] = None) -> str:
"""Créer un token JWT"""
to_encode = data.copy()
if expires_delta:
expire = datetime.now(timezone.utc) + expires_delta
else:
expire = datetime.now(timezone.utc) + timedelta(
minutes=settings.access_token_expire_minutes
)
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(
to_encode,
settings.secret_key,
algorithm=settings.algorithm
)
return encoded_jwt
def verify_token(token: str) -> Optional[dict]:
"""Vérifier et décoder un token JWT"""
try:
payload = jwt.decode(
token,
settings.secret_key,
algorithms=[settings.algorithm]
)
return payload
except JWTError:
return None