user

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

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	Id           _type.GormUlid        `json:"id" gorm:"primaryKey;size:26;not null"`
	FirstName    string                `json:"first_name" gorm:"size:100;not null"`
	LastName     string                `json:"last_name" gorm:"size:100;not null"`
	EmailAddress string                `json:"email_address" gorm:"size:100;not null"`
	PasswordHash password.PasswordHash `json:"-" gorm:"column:password;size:255;default:null"`
	Roles        []role.Role           `json:"roles" gorm:"many2many:user_roles"`
	CreatedAt    time.Time             `json:"created_at" gorm:"not null"`
	ModifiedAt   time.Time             `json:"modified_at" gorm:"not null"`
	DeletedAt    time.Time             `json:"deleted_at" gorm:"default:null"` // TODO: Make nullable/optional
}

func Register

func Register(id ulid.ULID, firstName string, lastName string, emailAddress string) *User

func (*User) AddRole

func (u *User) AddRole(role role.Role)

func (*User) Delete

func (u *User) Delete()

func (*User) HasPermission

func (u *User) HasPermission(name string) bool

func (*User) HasRole

func (u *User) HasRole(name string) bool

func (*User) IsDeleted

func (u *User) IsDeleted() bool

func (*User) Permissions

func (u *User) Permissions() []permission.Permission

func (*User) RemoveRole

func (u *User) RemoveRole(role role.Role)

func (*User) Restore

func (u *User) Restore()

func (*User) SetPasswordHash

func (u *User) SetPasswordHash(passwordHash password.PasswordHash)

func (*User) UpdateEmailAddress

func (u *User) UpdateEmailAddress(emailAddress string)

func (*User) UpdateFirstName

func (u *User) UpdateFirstName(firstName string)

func (*User) UpdateLastName

func (u *User) UpdateLastName(lastName string)

type UserRepository

type UserRepository interface {
	GetById(id ulid.ULID) (*User, error)
	GetByEmailAddress(emailAddress string) (*User, error)
	GetAll(includeDeleted bool) (*[]User, error)
	Add(user *User) error
	Remove(user *User) error
	UpdateOrAdd(user *User) error
}

Jump to

Keyboard shortcuts

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