Task Description: Implement a User Authentication System
Functionality to Implement:
Create a user authentication system that allows users to register, log in, and log out. The system should manage user credentials and provide secure access to the application.
Specific Requirements:
User Registration:
Implement a function to register a new user with a username and password.
Validate that the username is unique and is between 3 to 15 characters long.
Ensure the password is at least 8 characters long and contains at least one uppercase letter, one lowercase letter, and one number.
Store the user's credentials securely (e.g., hashed passwords) in a user database.
User Login:
Implement a function to log in a user using their username and password.
Validate the credentials against the stored user data.
If the login is successful, create and return a session token for the user.
If the login fails, return an appropriate error message.
User Logout:
Implement a function to log out the user by invalidating their session token.
Session Management:
Utilize an in-memory session store or a simple database to track active user sessions.
Ensure that session tokens are unique and expire after a set period of inactivity.
Testing:
Write unit tests for each of the above functionalities to ensure they work as expected and handle edge cases (e.g., invalid inputs, duplicate usernames).
The solution should be implemented in the /app/ directory with corresponding function definitions and securely handled user data using best practices.