Files
apskel-pos-backend/internal/service
efrilmandClaude Opus 5.5 8370851ed2 feat(loyalty): customer PIN
Adds the 6-digit customer PIN that approves every action moving EnakPoint
or EnakCoin on the customer's request (docs/prd-point-coin.md K8, F11, Q16,
Q17, PC-301).

Migration 000093 adds the PIN columns to customers and the
customer_security_events table. PIN data is read and written only through
CustomerPinRepository, never the Customer entity, so the hash cannot reach
a customer response. Only a bcrypt hash is stored.

- /customer/pin: status, OTP (pin_setup, pin_reset), create, change,
  reset. The OTP must be for that purpose and sent to the customer's own
  number; the existing OTP validation checks neither. A new PIN is checked
  (6 digits, confirmed, not one digit, not a run up or down, not the birth
  date as DDMMYY or YYMMDD) before the OTP is spent.
- Five wrong attempts in a row lock the PIN for 30 minutes; the counter is
  incremented in one statement so attempts at the same time all count,
  and a lock that ran out starts a new series. A locked PIN is refused even
  when right. The customer is told by WhatsApp, as there is no push channel
  to customers yet; only the attempt that reached the limit alerts.
- A reset through OTP lifts the lock and holds outgoing transfers for 24
  hours; paying and exchanging still work, and a held transfer costs no
  attempt.
- VerifyPin(ctx, customer, pin, action) for the flows that follow, with
  PIN_NOT_SET, PIN_INVALID (attempts left), PIN_LOCKED and
  TRANSFER_BLOCKED (until when), which PinErrorResponse turns into
  distinct codes and statuses.
- DELETE /marketing/customers/:id/pin (loyalty managers, reason required)
  and GET /marketing/customers/:id/security-events, scoped to the
  organization.

Every PIN event is in the security log with IP and user agent. No message
or binding error contains a PIN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:20:29 +07:00
..
2026-06-08 12:30:39 +07:00
2026-08-11 22:41:10 +07:00
2026-08-11 22:41:10 +07:00
2026-05-10 10:42:09 +07:00
2026-08-13 14:38:28 +07:00
2025-09-12 16:37:16 +07:00
2025-09-18 01:32:01 +07:00
2025-07-18 20:10:29 +07:00
2026-06-03 14:56:27 +07:00
2025-07-18 20:10:29 +07:00
2026-04-27 21:17:12 +07:00
2026-04-27 21:17:12 +07:00
2025-08-14 01:35:19 +07:00
2026-05-10 10:57:38 +07:00
2025-07-18 20:10:29 +07:00
2025-08-07 22:45:02 +07:00
2025-07-18 20:10:29 +07:00
2025-08-03 23:55:51 +07:00
2026-06-08 12:30:39 +07:00
2025-07-18 20:10:29 +07:00
2026-08-11 22:41:10 +07:00
2025-08-10 20:41:34 +07:00
2025-09-17 23:55:11 +07:00
2025-09-18 13:39:37 +07:00
2025-08-03 23:55:51 +07:00
2025-08-03 23:55:51 +07:00
2026-05-10 10:42:09 +07:00
2025-07-30 23:18:20 +07:00
2025-08-08 00:32:05 +07:00
2025-09-12 01:12:11 +07:00