Replaced config auth with db auth

This commit is contained in:
Jonas Linter
2025-12-02 16:43:56 +01:00
parent 7ff3c44747
commit 03aac27233
7 changed files with 83 additions and 30 deletions

View File

@@ -244,3 +244,26 @@ class HotelService:
)
)
return result.scalar_one_or_none()
async def authenticate_hotel(self, username: str, password: str) -> Hotel | None:
"""Authenticate a hotel using username and password.
Args:
username: AlpineBits username
password: Plain text password submitted via HTTP basic auth
Returns:
Hotel instance if the credentials are valid and the hotel is active,
otherwise None.
"""
hotel = await self.get_hotel_by_username(username)
if not hotel:
return None
if not password:
return None
if verify_password(password, hotel.password_hash):
return hotel
return None