Task Description: Implement User Authentication Functionality
Your task is to create a user authentication system within the application. This functionality should allow users to register, log in, and log out. The implementation should reside in the /app/ directory. Below are the specific requirements that must be met for the associated test code to pass:
User Registration:
Create a function register_user(username: str, password: str) -> bool that saves a new user with a unique username and hashed password.
Ensure that the username must be at least 3 characters long and cannot contain special characters.
If the username already exists, return False; otherwise, return True upon successful registration.
User Login:
Implement a function login_user(username: str, password: str) -> bool that checks if the provided username and password match a registered user.
If the username does not exist or the password is incorrect, return False. If they match, return True.
User Logout:
Create a function logout_user() -> None that will handle user logout. It should clear the current session or token.
Session Management:
Implement a simple session management system to keep track of logged-in users. Ensure that only one user can be logged in at a time and provide functions to get the currently logged-in user's username.
Security:
Use a secure hashing algorithm (e.g., bcrypt) for password storage to ensure that passwords are not stored in plaintext.
Testing:
Ensure all provided tests for user authentication are passing after implementation.
The implementation should be structured, documented, and adhere to common coding standards.