Implement a user authentication system in the application that meets the following requirements:
User Registration:
Create a method called register_user(username: str, password: str) -> bool in the /app/ directory that:
Accepts a username and password as parameters.
Validates that the username is not already taken (case-insensitive).
Validates that the password meets the following criteria:
At least 8 characters long.
Contains at least one uppercase letter.
Contains at least one lowercase letter.
Contains at least one digit.
Stores the user credentials securely (hashed) in a dictionary or an appropriate data structure.
Returns True if registration is successful; otherwise, returns False.
User Login:
Create a method called login_user(username: str, password: str) -> bool in the /app/ directory that:
Accepts a username and password as parameters.
Validates that the username exists (case-insensitive).
Checks that the provided password matches the stored hash for that username.
Returns True if login is successful; otherwise, returns False.
Password Security:
Implement password hashing for storing user passwords securely. Use a suitable library (e.g., bcrypt) to handle password hashing and verification.
Error Handling:
Ensure the methods do not throw uncaught exceptions. Use exception handling to manage invalid inputs and potential errors gracefully.
By fulfilling these requirements, you will ensure that the provided test cases in the accompanying test code pass successfully, covering both the user registration and login functionalities. Place your implementation in the /app/ directory.