POST /users/{id}/promote and /demote set a user's role (admin/user), admin-only
(403 otherwise). Mirrors the verify endpoints: SetRole use case + repo method,
validated role. Unit, admin-flow, and integration tests included.
20 lines
698 B
Go
20 lines
698 B
Go
package usecase
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
// Repository-contract errors, returned by UserRepository implementations.
|
|
ErrEmailExists = errors.New("email already registered")
|
|
ErrUserNotFound = errors.New("user not found")
|
|
|
|
// Use-case errors surfaced to the transport layer.
|
|
//
|
|
// ErrInvalidCredentials is deliberately returned for both an unknown email
|
|
// and a wrong password, so an attacker cannot use the response to learn
|
|
// which emails are registered.
|
|
ErrInvalidCredentials = errors.New("invalid email or password")
|
|
ErrPasswordTooShort = errors.New("password too short")
|
|
ErrPasswordTooLong = errors.New("password too long")
|
|
ErrInvalidRole = errors.New("invalid role")
|
|
)
|