59c582d13c
- Create model/errors.go to centralize all sentinel errors - ValidateAccessToken now returns error to distinguish DB failures - ValidateUserToken uses unified ErrTokenInvalid for all auth failures (expired/exhausted/disabled/not-found) to prevent token enumeration - authHelper and TokenAuthReadOnly use i18n messages instead of hardcoded Chinese strings - All err.Error() removed from user-facing responses; DB errors logged server-side and return generic "contact admin" message (HTTP 500) - Migrate ErrRedeemFailed, ErrTwoFANotEnabled to model/errors.go
27 lines
529 B
Go
27 lines
529 B
Go
package model
|
|
|
|
import "errors"
|
|
|
|
// Common errors
|
|
var (
|
|
ErrDatabase = errors.New("database error")
|
|
)
|
|
|
|
// User auth errors
|
|
var (
|
|
ErrInvalidCredentials = errors.New("invalid credentials")
|
|
ErrUserEmptyCredentials = errors.New("empty credentials")
|
|
)
|
|
|
|
// Token auth errors
|
|
var (
|
|
ErrTokenNotProvided = errors.New("token not provided")
|
|
ErrTokenInvalid = errors.New("token invalid")
|
|
)
|
|
|
|
// Redemption errors
|
|
var ErrRedeemFailed = errors.New("redeem.failed")
|
|
|
|
// 2FA errors
|
|
var ErrTwoFANotEnabled = errors.New("2fa not enabled")
|