Build a login system
Build a local login app, prove its boundaries, and explain your decisions in an interview.
Your brief
Build a local app where a user registers, logs in, refreshes without losing their session, reads an authorized invoice, and logs out.
Start with JavaScript functions, maps, and async requests. Review backend foundations whenever a concept is unfamiliar.
The starter provides an HTTP adapter, browser form, and password helpers. Implement the missing model and cookie functions. Accounts live in memory; sessions last 60 seconds. Use fake credentials.
Save both starter files in one folder. Run node starter.mjs and open http://127.0.0.1:3210. Use Node.js 22.12+; no packages are needed. TODO errors are expected until each step is implemented.
0 / 6 steps verified by you. Checks are self-reported; this website does not execute your code.
- 1
Register a user and hash the password
Turn a submitted identity into a stored account without retaining the password.
- 2
Log in and issue a session
Verify credentials and return an unpredictable, limited-lifetime identifier.
- 3
Stay logged in after refreshing
Let the browser send a cookie and let the server decide whether it is valid.
- 4
Protect an endpoint and check ownership
A valid login is only the first check before returning a private record.
- 5
Handle expiry and logout
End authority on the server, including when an old cookie is replayed.
- 6
Test the failures and defend your design
Use evidence from the implementation to answer follow-up interview questions.