42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package user
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
var ErrUserNotFound = errors.New("user not found")
|
|
var ErrInvalidCredentials = errors.New("invalid credentials")
|
|
var ErrRegistrationClosed = errors.New("registration closed")
|
|
var ErrInvalidVerificationCode = errors.New("invalid verification code")
|
|
var ErrVerificationCodeExpired = errors.New("verification code expired")
|
|
var ErrAlreadyVerified = errors.New("user already verified")
|
|
var ErrInvalidPasswordResetCode = errors.New("invalid password reset code")
|
|
var ErrPasswordResetCodeExpired = errors.New("password reset code expired")
|
|
var ErrInvalidDisplayName = errors.New("invalid display name")
|
|
var ErrUsernameTaken = errors.New("username taken")
|
|
|
|
type Role string
|
|
|
|
const (
|
|
RoleOwner Role = "owner"
|
|
RoleAdmin Role = "admin"
|
|
)
|
|
|
|
type User struct {
|
|
ID uint32 `json:"id"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
PasswordResetCode string `json:"password_reset_code"`
|
|
Email string `json:"email"`
|
|
DisplayName string `json:"display_name"`
|
|
IsVerified bool `json:"is_verified"`
|
|
Role Role `json:"role"`
|
|
VerificationCode string `json:"verification_code"`
|
|
VerificationExpiration time.Time `json:"verification_expiration"`
|
|
PasswordResetExpiration time.Time `json:"password_reset_expiration"`
|
|
TokenVersion uint32 `json:"token_version"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|