models

package
v0.0.0-...-5ef567c Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryEmailOTP          = "email_otp"
	CategoryEmailVerification = "email_verification"
)
View Source
const (
	OrganizationRoleMember = "member"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IdentityAndOrgRecord

type IdentityAndOrgRecord struct {
	ID                  uuid.UUID  `bun:"id,pk" json:"id"`
	Email               string     `bun:"email" json:"email"`
	Enabled             bool       `bun:"enabled" json:"enabled"`
	EmailVerifiedAt     *time.Time `bun:"email_verified_at" json:"-"`
	FailedLoginAttempts int        `bun:"failed_login_attempts" json:"-"`
	LockExpiresAt       time.Time  `bun:"lock_expires_at" json:"-"`
	HashedPassword      string     `bun:"hashed_password" json:"-"`
	LastLoginAt         time.Time  `bun:"last_login_at" json:"-"`
	CreatedAt           time.Time  `bun:"created_at" json:"-"`
	UpdatedAt           time.Time  `bun:"updated_at" json:"-"`
	OrgRoles            []string   `bun:"org_roles" json:"roles"`
	OrgID               uuid.UUID  `bun:"org_id" json:"org_id"`
	OrgName             string     `bun:"org_name" json:"org_name"`
	OrgSlug             string     `bun:"org_slug" json:"org_slug"`
	OrgEnabled          bool       `bun:"org_enabled" json:"org_enabled"`
}

type IdentityModel

type IdentityModel struct {
	bun.BaseModel       `bun:"table:identities,alias:ids"`
	ID                  uuid.UUID  `bun:"id,pk"`
	Email               string     `bun:"email"`
	HashedPassword      string     `bun:"hashed_password"`
	Enabled             bool       `bun:"enabled"`
	EmailVerifiedAt     *time.Time `bun:"email_verified_at"`
	FailedLoginAttempts int        `bun:"failed_login_attempts"`
	LockExpiresAt       time.Time  `bun:"lock_expires_at"`
	LastLoginAt         time.Time  `bun:"last_login_at"`
	CreatedAt           time.Time  `bun:"created_at"`
	UpdatedAt           time.Time  `bun:"updated_at"`
}

type LoginWithEmailAndPasswordRequest

type LoginWithEmailAndPasswordRequest struct {
	Email    string `json:"email" validate:"email,required,max=100"`
	Password string `json:"password" validate:"required,min=8,max=50"`
}

type LoginWithEmailOTPRequest

type LoginWithEmailOTPRequest struct {
	Email string `json:"email" validate:"required,max=100,email"`
}

type NewOrgRequest

type NewOrgRequest struct {
	Name string `json:"name" validate:"required,max=100"`
	Slug string `json:"slug" validate:"required,max=20"`
}

type NewOrgResponse

type NewOrgResponse struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type OneTimeTokenModel

type OneTimeTokenModel struct {
	bun.BaseModel `bun:"table:one_time_tokens,alias:ott"`
	ID            uuid.UUID `bun:"id,pk"`
	HashedCode    string    `bun:"hashed_code"`
	Category      string    `bun:"category"`
	IdentityID    uuid.UUID `bun:"identity_id"`
	Used          bool      `bun:"used"`
	ExpiresAt     time.Time `bun:"expires_at"`
	CreatedAt     time.Time `bun:"created_at"`
}

type OrganizationMembershipModel

type OrganizationMembershipModel struct {
	bun.BaseModel  `bun:"table:organization_members,alias:membership"`
	OrganizationID uuid.UUID `bun:"organization_id"`
	IdentityID     uuid.UUID `bun:"identity_id"`
	Roles          []string  `bun:"roles"`
	Home           bool      `bun:"home"`
	CreatedAt      time.Time `bun:"created_at"`
	UpdatedAt      time.Time `bun:"updated_at"`
}

type OrganizationModel

type OrganizationModel struct {
	bun.BaseModel `bun:"table:organizations,alias:org"`
	ID            uuid.UUID `bun:"id,pk"`
	Name          string    `bun:"name"`
	Slug          string    `bun:"slug"`
	Enabled       bool      `bun:"enabled"`
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
}

type PrincipalClaims

type PrincipalClaims struct {
	IdentityID uuid.UUID `json:"identity_id"`
	OrgID      uuid.UUID `json:"org_id"`
	Roles      []string  `json:"roles"`
}

func (PrincipalClaims) HasRole

func (c PrincipalClaims) HasRole(theRole string) bool

type SignInResponse

type SignInResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
}

type VerifyEmailOTPRequest

type VerifyEmailOTPRequest struct {
	Code  string `json:"code" validate:"required,len=6"`
	Email string `json:"email" validate:"email,required,max=100"`
}

Jump to

Keyboard shortcuts

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