org

package
v0.0.0-...-16952c6 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package org contains package methods for org support.

Index

Constants

View Source
const SchemaVersion = 0

Variables

This section is empty.

Functions

func Users

func Users(
	ctx context.Context,
	conn *pgx.Conn,
	id models.ID,
) ([]models.ID, error)

Users returns the list of user ids in the org.

Types

type CreateEvent

type CreateEvent struct {
	Name             safe.VarChar  `json:"name"`
	OwnerDisplayName safe.VarChar  `json:"owner_display_name"`
	OwnerEmail       safe.VarChar  `json:"owner_email"`
	OwnerPassword    safe.Password `json:"owner_password"`
	Role             models.Role   `json:"role"`
	// contains filtered or unexported fields
}

func NewCreateEvent

func NewCreateEvent(argon2Config *argon2.Config) (*CreateEvent, error)

func (*CreateEvent) UnmarshalJSON

func (ev *CreateEvent) UnmarshalJSON(bs []byte) error

UnmarshalJSON assumes OwnerPassword is cleartext and hashes it with argon2. This minimizes the window to access the cleartext password accidentally.

type Org

type Org struct {
	models.Base
	Name  safe.VarChar `json:"name"`
	Owner models.ID    `json:"owner"`
}

Org models a row of the orgs table.

func Create

func Create(
	ctx context.Context,
	conn *pgx.Conn,
	name safe.VarChar,
	ownerDisplayName safe.VarChar,
	ownerEmail safe.VarChar,
	ownerPassword safe.Password,
	role models.Role,
	versionKey *security.VersionKey,
) (*Org, *user.User, error)

Create inserts a new org and org owner into the db.

func Read

func Read(
	ctx context.Context,
	conn *pgx.Conn,
	id models.ID,
) (*Org, error)

Read initializes a User from an existing row.

func (*Org) GetID

func (o *Org) GetID() models.ID

GetID implements models.WithID.

func (*Org) GetOrg

func (o *Org) GetOrg() models.ID

GetOrg implements models.WithOrg.

func (*Org) GetUser

func (o *Org) GetUser() models.ID

GetOrg implements models.WithUser.

func (*Org) Insert

func (o *Org) Insert(ctx context.Context, conn *pgx.Conn) error

Insert an Org into the db.

func (*Org) Refresh

func (o *Org) Refresh(ctx context.Context, conn *pgx.Conn) error

Refresh will re-initialize data fields after an update, typically inside the same txn that performed the update.

func (*Org) UpdateOwner

func (o *Org) UpdateOwner(ctx context.Context,
	conn *pgx.Conn,
	newOwner models.ID,
) error

UpdateOwner assigns a new user in the org as the owner.

func (*Org) UpdateStatus

func (o *Org) UpdateStatus(ctx context.Context,
	conn *pgx.Conn,
	newStatus models.Status,
) error

UpdateStatus changes the org status.

type UpdateOwnerEvent

type UpdateOwnerEvent struct {
	Owner models.ID `json:"owner"`
}

type UpdateStatusEvent

type UpdateStatusEvent struct {
	Status models.Status `json:"status"`
}

Jump to

Keyboard shortcuts

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