Prompt Details
Model
Chat - (gpt-5.4)
Token size
338
Example input
[LANGUAGE]: Python
[PURPOSE]: User login authentication
[CODE]: def login(u,p): return u=="admin" and p=="1234"
Example output
Alright, I’m going to treat this like a real production review — not just nitpicking, but what would actually get flagged at a serious company.
## 1. CRITICAL ISSUES 🔴
Hardcoded credentials (major security vulnerability)
You’re literally embedding "admin" and "1234" in code. This is a huge red flag:
Anyone with code access gets the credentials instantly
Impossible to rotate credentials safely
Violates every basic security practice
Plaintext password comparison
Passwords should never be stored or compared in plaintext.
No hashing
No salting
Easily compromised
No protection against brute force attacks
No rate limiting
No lockout mechanism
No logging of failed attempts
No user abstraction / scalability
Only supports one user
Not connected to any database or user store
## 2. PERFORMANCE 🟡
For this tiny function, performance isn’t the main concern, but:
String comparison is O(n), which is fine here
Bigger issue: design doesn’t scale at all
You’ll end up rewriting everything once you add real users
## 3. CODE QUALITY 🟢
What’s okay:
Simple and readable
Clear intent
What needs improvement:
No type hints
No docstring
No separation of concerns (auth logic vs data storage)
Magic values ("admin", "1234")
## 4. IMPROVED VERSION
Here’s a minimum production-style improvement using hashing and a mock user store:
Python
import hashlib
from typing import Dict
# Mock database (in real life: use a real DB)
users_db: Dict[str, str] = {
"admin": hashlib.sha256("1234".encode()).hexdigest()
}
def hash_password(password: str) -> str:
return hashlib.sha256(password.encode()).hexdigest()
def login(username: str, password: str) -> bool:
stored_password_hash = users_db.get(username)
if not stored_password_hash:
return False
return stored_password_hash == hash_password(password)
Better (real-world recommendation):
Use bcrypt instead of SHA256
Add rate limiting
Add logging
Move user storage to a database
## 5. SCORE CARD
Category
Score
Notes
Security
1/10
Critical vulnerabilities
Performance
5/10
Fine for toy example
Scalability
1/10
Not usable beyond demo
Code Quality
4/10
Clean but too naive
Overall
2/10
Needs redesign for real use
## 6. LEARNING MOMENT
If you remember only one thing, remember this:
Authentication is a security problem first, not a logic problem.
Beginner mistake is thinking:
“Does this function return True or False correctly?”
Senior mindset is:
“Can this system be attacked, abused, or bypassed?”
If you want, I can level this up to:
�JWT-based auth system
�Full FastAPI login endpoint
�Production-ready architecture (with refresh tokens, hashing, etc.)
Just tell me 👍
By purchasing this prompt, you agree to our terms of service
GPT-5.4
Get a professional-grade code review from a Staff Engineer perspective.
This prompt analyzes your code and delivers:
✅ Critical issues & security vulnerabilities
✅ Performance analysis with Big O notation
✅ Improved version with inline comments
✅ Score card (Security, Performance, Readability)
✅ One key learning concept to level up
Works with any programming language.
Perfect for developers, students, and bootcamp graduates.
...more
Added 2 weeks ago
