Replaced config auth with db auth
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user