Skip to content

domain ​

go
import "github.com/prescriptoo/prescriptoo-api/services/identity/internal/domain"

Package domain contains core business entities for the identity service.

Index ​

Variables ​

go
var (
    // ErrUserNotFound indicates that a user record does not exist.
    ErrUserNotFound = errors.New("user not found")
    // ErrUserAlreadyExists indicates that the email belongs to an existing user.
    ErrUserAlreadyExists = errors.New("user with this email already exists")
    // ErrInvalidCredentials indicates that the supplied email or password is incorrect.
    ErrInvalidCredentials = errors.New("invalid email or password")
    // ErrInvalidToken indicates that an authentication token is invalid or expired.
    ErrInvalidToken = errors.New("invalid or expired token")
    // ErrProfileNotFound indicates that a user profile does not exist.
    ErrProfileNotFound = errors.New("profile not found")
    // ErrAccountDisabled indicates that an account is not allowed to sign in.
    ErrAccountDisabled = errors.New("account is not permitted to sign in")
    // ErrInvalidInput indicates that authentication input is invalid.
    ErrInvalidInput = errors.New("invalid authentication input")
    // ErrRateLimited indicates that the request limit has been reached.
    ErrRateLimited = errors.New("too many requests; try again later")
    // ErrInvalidEmailToken indicates that an email token is invalid or expired.
    ErrInvalidEmailToken = errors.New("invalid or expired email token")
    // ErrCurrentPassword indicates that the supplied current password is incorrect.
    ErrCurrentPassword = errors.New("current password is incorrect")
    // ErrSessionNotFound indicates that a session record does not exist.
    ErrSessionNotFound = errors.New("session not found")
)

type EmailPurpose ​

EmailPurpose separates verification credentials from password-reset credentials.

go
type EmailPurpose string

Supported identity email purposes.

go
const (
    EmailVerification EmailPurpose = "verification"
    PasswordReset     EmailPurpose = "password_reset"
)

type Session ​

Session represents a login with a fixed expiration and a rotating refresh token.

go
type Session struct {
    ID, UserID, RefreshTokenHash                 string
    ExpiresAt                                    time.Time
    CreatedAt, LastActiveAt                      time.Time
    DeviceName, DeviceType, IPAddress, UserAgent string
}

type TokenPair ​

TokenPair represents access and refresh tokens.

go
type TokenPair struct {
    AccessToken  string
    RefreshToken string
    ExpiresIn    int64
}

type User ​

User represents the base user identity.

go
type User struct {
    types.Entity
    Email         types.Email
    PasswordHash  string
    Name          string
    Phone         string
    AvatarURL     string
    Status        UserStatus
    EmailVerified bool
}

type UserStatus ​

UserStatus represents the current state of an identity account.

go
type UserStatus string

go
const (
    // UserStatusActive marks an active account.
    UserStatusActive UserStatus = "active"
    // UserStatusInactive marks an inactive account.
    UserStatusInactive UserStatus = "inactive"
    // UserStatusBanned marks a suspended account.
    UserStatusBanned UserStatus = "suspended"
)

func (UserStatus) IsValid ​

go
func (s UserStatus) IsValid() bool

IsValid reports whether the status is one of the supported account states.

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.