Task Description: Implement a User Authentication System
You need to implement a User Authentication System in the /app/ directory that fulfills the following requirements to ensure that the provided test code passes:
User Registration:
Create a function register_user(username: str, password: str) -> bool that registers a new user.
The function should check if the username already exists. If it does, return False. If not, store the username and a hashed version of the password in a persistent data store (e.g., a dictionary for simplicity).
User Login:
Create a function login_user(username: str, password: str) -> bool that allows a registered user to log in.
The function should verify that the username exists and that the provided password matches the stored hashed password. If both conditions are satisfied, return True; otherwise, return False.
Password Hashing:
Use a hashing function (e.g., SHA-256) to securely store passwords. Ensure that you do not store plain text passwords in your data store.
Session Management:
Once a user logs in successfully, store their login session in a global variable or a session store, so they remain logged in until they choose to log out.
Implement a function logout_user() -> None that clears the user’s session.
Error Handling:
Both register_user and login_user functions should handle any potential exceptions (e.g., invalid input, empty strings) gracefully and return False.
Organize your code clearly within the /app/ directory, and ensure all functionalities are thoroughly tested. Following these requirements will ensure that all existing tests pass successfully.