
- Updated
Add secure login to a web app
This prompt helps you add login without the usual security mistakes. It first asks whether a trusted library or service fits better, then walks through hashing, sessions, cookies, rate limiting and password reset.
Act as a security-minded backend developer. Stack: [e.g. Express + Postgres, or Django] Login type: [e.g. email and password with email verification] Explain whether I should use a trusted library or service instead of building this myself, and recommend one for my stack. Then show the setup: password hashing, sessions or tokens, cookie settings, rate limiting on login, password reset with expiring links, and logout. Point out the five most common security mistakes in login code and how this setup avoids them.
For real users, a well-known auth library or service is almost always safer than hand-written login code.
Get a better result
Advice on whether to use a trusted auth library or service for your stack, then a setup covering password hashing, sessions or tokens, cookie flags, login rate limits, expiring reset links and logout, plus five common login mistakes and how this avoids them.
The first instruction asks whether you should build this at all, which is the most useful security advice for most apps. Naming your stack gets setup code that fits it, not a generic sketch. Listing every piece, from cookie flags to logout, stops the model from stopping at a happy path login form, which is where most homemade login code goes wrong.
It writes password hashing with a general purpose hash.
Fix: Ask for a slow password hashing function made for the job, such as bcrypt, scrypt or Argon2, and never a plain fast hash.
- The reset link never expires and can be used twice. Ask for a single use token that expires within an hour and is stored hashed, so a leaked database does not leak working links.
- The login error says whether the email exists. Ask for the same message for a wrong email and a wrong password, so attackers cannot test which accounts exist.
Ask how to add one social login next to email and password, and how to link the two when the same person uses both.
Now walk through this setup as an attacker would. List what you would try first and how the setup stops each attempt.
More chat & writing prompts
See all 465 →More like this
- Upgrade a library to a new major versionClaude · ChatGPT · Claude Code
- Automate Google Sheets with Apps ScriptClaude · ChatGPT · Gemini
- Improve error handling in your codeClaude · ChatGPT · Gemini
- Write a Dockerfile for your appClaude · ChatGPT · Claude Code
- Build a small command-line toolClaude · ChatGPT · Gemini



