backend-server-v2/codex-prompt/prompt-3.txt

19 lines
710 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Implementa internal/models e internal/auth.
- internal/models/user.go:
- User: ID, Email unique, PasswordHash, EmailVerified, Role (default user), timestamps.
- internal/models/auth_tokens.go:
- EmailVerificationToken: UserID, TokenHash unique, ExpiresAt, timestamps
- PasswordResetToken: UserID, TokenHash unique, ExpiresAt, timestamps
- internal/auth/passwords.go:
- HashPassword(plain) -> hash (bcrypt)
- ComparePassword(hash, plain) -> bool/error
- internal/auth/tokens.go:
- NewToken() -> plainToken (base64url random 32+ bytes)
- HashToken(plainToken) -> hex/bytes SHA-256 string
- ExpiresAt helpers (verify 24h, reset 1h)
Assicurati che nel DB venga salvato SOLO lhash del token.