Files
apskel-pos-backend/internal/repository
efrilmandClaude Opus 5.5 a01e651709 fix(customer-auth): refuse a wrong login with 304 and limit attempts
A wrong password or an unknown phone number was answered 900 (HTTP 500), like a
server error, so clients could only tell them apart by the cause text. Both are
now 304 (HTTP 400) from customer_auth_service with one cause, "invalid phone
number or password", so a login does not tell which numbers have an account. A
customer who never set a password gets 304 "customer not properly registered".
Anything else stays 900.

Login is limited per phone number: 5 attempts in 15 minutes, counted in Redis
before the password is checked, so attempts sent at once all count, and for
numbers without a customer too. The sixth is refused with 429 and
data.locked_until, even with the right password, until the window ends. A
successful login starts the count again. Since the number is normalized first,
0812… and 62812… count as one. When Redis fails, logins go on unlimited and the
error is logged.

There is no limit per IP: the client IP comes from X-Forwarded-For, which anyone
can set while no trusted proxies are configured.

Tested over HTTP with fakes; the Redis commands were checked against miniredis
outside the repo, not against a real Redis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 22:59:27 +07:00
..
2025-09-18 13:39:37 +07:00
2026-08-13 14:38:28 +07:00
2025-09-12 16:37:16 +07:00
2026-05-10 10:57:38 +07:00
2025-09-18 12:01:20 +07:00
2025-08-13 23:14:26 +07:00
2026-08-11 20:47:38 +07:00
2026-08-11 22:41:10 +07:00
2026-05-10 14:52:02 +07:00
2025-09-17 19:30:17 +07:00
2026-05-10 10:42:09 +07:00
2026-05-10 23:36:22 +07:00