fix: 7 Bugs behoben – Backend+Frontend lauffähig getestet

Backend-Fixes:
- vehicles-Relation in Account-Model ergänzt (500er bei Auth)
- security.py: bcrypt direkt statt passlib (bcrypt 5.x-Kompatibilität)
- auth.py Login: selectinload(User.role) gegen Lazy-Loading-500er
- equipment_group.py: LocationRef-Import via TYPE_CHECKING

Frontend-Fixes:
- api.ts: Python-Docstring durch JS-Kommentar ersetzt
- AppLayout.tsx: AddressBook→Contact (existiert nicht in lucide-react)
- package.json: axios-Dependency ergänzt

Tests bestanden:
- Health 200, Register 201, Login 200, Projects CRUD 200, alle API-Listen 200
- tsc --noEmit: sauber, vite build: erfolgreich
This commit is contained in:
Agent Zero
2026-05-31 20:49:10 +00:00
parent ddd603f177
commit e4830549ac
7 changed files with 311 additions and 24 deletions
+4 -1
View File
@@ -3,6 +3,7 @@
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload
from app.api.deps import get_current_user
from app.core.security import (
@@ -116,7 +117,9 @@ async def login(
session: AsyncSession = Depends(get_async_session),
):
"""Authenticate user with email and password."""
result = await session.execute(select(User).where(User.email == body.email))
result = await session.execute(
select(User).options(selectinload(User.role)).where(User.email == body.email)
)
user = result.scalars().first()
if not user or not verify_password(body.password, user.password_hash):
+5 -5
View File
@@ -3,22 +3,22 @@
from datetime import datetime, timedelta, timezone
from typing import Any
import bcrypt
from jose import jwt
from passlib.context import CryptContext
from app.core.config import settings
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def verify_password(plain_password: str, hashed_password: str) -> bool:
"""Verify a plaintext password against a bcrypt hash."""
return pwd_context.verify(plain_password, hashed_password)
return bcrypt.checkpw(
plain_password.encode("utf-8"), hashed_password.encode("utf-8")
)
def get_password_hash(password: str) -> str:
"""Hash a password using bcrypt."""
return pwd_context.hash(password)
return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")
def create_access_token(subject: str | Any, expires_delta: timedelta | None = None) -> str:
+1
View File
@@ -31,4 +31,5 @@ class Account(Base):
stock_locations: Mapped[list["StockLocation"]] = relationship("StockLocation", back_populates="account")
equipment_groups: Mapped[list["EquipmentGroup"]] = relationship("EquipmentGroup", back_populates="account")
crew_members: Mapped[list["Crew"]] = relationship("Crew", back_populates="account")
vehicles: Mapped[list["Vehicle"]] = relationship("Vehicle", back_populates="account")
projects: Mapped[list["Project"]] = relationship("Project", back_populates="account")