models

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	bun.BaseModel `bun:"table:auth_accounts,alias:a"`

	ID        uuid.UUID `bun:"id,pk,type:uuid" json:"id"`
	CreatedAt time.Time `bun:"created_at,nullzero,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,nullzero,notnull" json:"updated_at"`

	Native     *NativeAccount `bun:"rel:has-one,join:id=account_id" json:"native,omitempty"`
	OAuthLinks []*OAuthLink   `bun:"rel:has-many,join:id=account_id" json:"oauth_links,omitempty"`
}

Account is the identity — "you exist"

type CreateProfileRequest added in v0.2.0

type CreateProfileRequest struct {
	DisplayName string `json:"display_name" binding:"required,min=2,max=32"`
}

type DeleteAccountRequest

type DeleteAccountRequest struct {
	Password string `json:"password" binding:"required"`
}

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Message string `json:"message,omitempty"`
}

type ForgotPasswordRequest

type ForgotPasswordRequest struct {
	Email string `json:"email" binding:"required,email"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type NativeAccount

type NativeAccount struct {
	bun.BaseModel `bun:"table:auth_native,alias:n"`

	ID           uuid.UUID `bun:"id,pk,type:uuid" json:"id"`
	AccountID    uuid.UUID `bun:"account_id,notnull,type:uuid" json:"account_id"`
	Email        string    `bun:"email,notnull,unique" json:"email"`
	Username     string    `bun:"username,notnull,unique" json:"username"`
	PasswordHash string    `bun:"password_hash,notnull" json:"-"`
	CreatedAt    time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp" json:"created_at"`

	Account *Account `bun:"rel:belongs-to,join:account_id=id" json:"-"`
}

NativeAccount is email/password authentication

type OAuthLink struct {
	bun.BaseModel `bun:"table:auth_oauth,alias:o"`

	ID            uuid.UUID `bun:"id,pk,type:uuid" json:"id"`
	AccountID     uuid.UUID `bun:"account_id,notnull,type:uuid" json:"account_id"`
	Provider      string    `bun:"provider,notnull" json:"provider"`
	ProviderID    string    `bun:"provider_id,notnull" json:"provider_id"`
	ProviderEmail string    `bun:"provider_email" json:"provider_email,omitempty"`
	CreatedAt     time.Time `bun:"created_at,notnull" json:"created_at"`

	Account *Account `bun:"rel:belongs-to,join:account_id=id" json:"-"`
}

OAuthLink is a provider login linked to an account

type OTPCode

type OTPCode struct {
	bun.BaseModel `bun:"table:auth_otp_codes,alias:otp"`

	ID        uuid.UUID `bun:"id,pk,type:uuid" json:"id"`
	Email     string    `bun:"email,notnull" json:"email"`
	Code      string    `bun:"code,notnull" json:"code"`
	Type      string    `bun:"type,notnull" json:"type"`
	ExpiresAt time.Time `bun:"expires_at,notnull" json:"expires_at"`
	CreatedAt time.Time `bun:"created_at,notnull" json:"created_at"`
	Metadata  string    `bun:"metadata" json:"metadata,omitempty"`
}

type PasswordChangeRequest

type PasswordChangeRequest struct {
	CurrentPassword string `json:"current_password" binding:"required"`
	NewPassword     string `json:"new_password" binding:"required,min=8"`
}

type Profile added in v0.2.0

type Profile struct {
	bun.BaseModel `bun:"table:profiles,alias:p"`

	AccountID   uuid.UUID `bun:"account_id,pk,type:uuid" json:"account_id"`
	DisplayName string    `bun:"display_name,notnull" json:"display_name"`
	CreatedAt   time.Time `bun:"created_at,notnull" json:"created_at"`
	UpdatedAt   time.Time `bun:"updated_at,notnull" json:"updated_at"`
}

type RegisterRequest

type RegisterRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Username string `json:"username" binding:"required,min=3,max=32"`
	Password string `json:"password" binding:"required,min=8"`
}

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Code        string `json:"code" binding:"required"`
	NewPassword string `json:"new_password" binding:"required,min=8"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	AccountID   string `json:"account_id"`
}

type UpdateProfileRequest added in v0.2.0

type UpdateProfileRequest struct {
	DisplayName string `json:"display_name" binding:"omitempty,min=2,max=32"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址