Authentication verifies a person's identity before allowing access to an account or its resources. In a CRUD application, it connects account creation, login, logout, and private data management. section 8.1.1 section 8.1.2
A practical authentication flow typically includes:
- A signup page where a user chooses a username and password. section 8.1.2
- A login page where the application checks the supplied credentials. section 8.1.2 section 8.4.2
- A logged-in experience where users manage their own private records. section 8.1.1 section 8.1.2
Keep user-related logic in a UserService. Its get_authenticated_user method looks up the username, asks the User object to authenticate the password, returns the user on success, and returns None otherwise. The login page stores logged_in and the authenticated user in Streamlit session state, then displays a success or error message. section 8.4.2
A failed login
If the username does not exist or the password is incorrect, authentication returns None and the interface shows “Invalid username or password.” The implementation deliberately uses the same result for both cases, although distinguishing them can matter in other designs. section 8.4.2
Figure 8.1 Rough sketches of the pages we want in Haiku Haven
Use the page sketches to compare signup, login, logout, and logged-in CRUD experiences before implementing the interface. section 8.1.2
Never store passwords as plain text. Hash passwords with a library such as bcrypt, store the resulting hash, and compare it with a hash of the supplied password during authentication. Advanced security features remain outside this basic implementation. section 8.7 section 8.1.1

































