store

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword added in v0.0.3

func HashPassword(plaintextPassword string) (string, error)

HashPassword will take a string and return a string copy of a bcrypt hashed password.

func Matches added in v0.0.3

func Matches(plaintextPassword, hashedPassword string) (bool, error)

Matches will return true if the provided plaintextPassword matches the hashedPassword.

func NewDatabasePool

func NewDatabasePool(ctx context.Context, cfg *config.Conf) (*pgxpool.Pool, error)

Types

type CreateTeamParams added in v0.0.3

type CreateTeamParams struct {
	UserID pgtype.Text `json:"user_id"`
	Name   string      `json:"name"`
}

type CreateTeamRow added in v0.0.3

type CreateTeamRow struct {
	Name         string      `json:"name"`
	Uuid         string      `json:"uuid"`
	PersonalTeam pgtype.Bool `json:"personal_team"`
}

type CreateUserWithNewTeamParams added in v0.0.3

type CreateUserWithNewTeamParams struct {
	Column1  pgtype.Text `json:"column_1"`
	Name     pgtype.Text `json:"name"`
	Email    pgtype.Text `json:"email"`
	Password pgtype.Text `json:"password"`
}

type CreateUserWithNewTeamRow added in v0.0.3

type CreateUserWithNewTeamRow struct {
	UserID              string `json:"user_id"`
	TeamID              string `json:"team_id"`
	PersonalAccessToken string `json:"personal_access_token"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetUserByIDParams added in v0.0.3

type GetUserByIDParams struct {
	Uuid   string      `json:"uuid"`
	UserID pgtype.Text `json:"user_id"`
}

type GetUserByIDRow added in v0.0.3

type GetUserByIDRow struct {
	Uuid      string             `json:"uuid"`
	Name      pgtype.Text        `json:"name"`
	Email     pgtype.Text        `json:"email"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	Role      UserRole           `json:"role"`
}

type ListUsersParams added in v0.0.3

type ListUsersParams struct {
	TeamID pgtype.Text `json:"team_id"`
	Limit  int32       `json:"limit"`
	Offset int32       `json:"offset"`
}

type ListUsersRow added in v0.0.3

type ListUsersRow struct {
	ID        int32              `json:"id"`
	Name      pgtype.Text        `json:"name"`
	Email     pgtype.Text        `json:"email"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	Role      UserRole           `json:"role"`
}

type NullUserRole added in v0.0.3

type NullUserRole struct {
	UserRole UserRole `json:"user_role"`
	Valid    bool     `json:"valid"` // Valid is true if UserRole is not NULL
}

func (*NullUserRole) Scan added in v0.0.3

func (ns *NullUserRole) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUserRole) Value added in v0.0.3

func (ns NullUserRole) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type PersonalAccessTokens added in v0.0.3

type PersonalAccessTokens struct {
	ID            int64              `json:"id"`
	TokenableType string             `json:"tokenable_type"`
	TokenableID   string             `json:"tokenable_id"`
	Name          string             `json:"name"`
	Token         string             `json:"token"`
	Abilities     pgtype.Text        `json:"abilities"`
	LastUsedAt    pgtype.Timestamptz `json:"last_used_at"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CountUsers added in v0.0.3

func (q *Queries) CountUsers(ctx context.Context, teamID pgtype.Text) (int64, error)

$2 is the UUID of the authenticated user Count all users the authorized user can see; used in pagination

func (*Queries) CreateTeam added in v0.0.3

func (q *Queries) CreateTeam(ctx context.Context, arg CreateTeamParams) (CreateTeamRow, error)

Create a new team. Can only be created by a user with admin privileges

func (*Queries) CreateUserWithNewTeam added in v0.0.3

func (q *Queries) CreateUserWithNewTeam(ctx context.Context, arg CreateUserWithNewTeamParams) (CreateUserWithNewTeamRow, error)

Create a new user and a team for them. This is only done once when a user is registered. All other team creation is done via CreateTeam and users must be manually invited into the new team.

func (*Queries) DoesAdminExist added in v0.0.3

func (q *Queries) DoesAdminExist(ctx context.Context) (bool, error)

Create admin user (for initial setup only)

func (*Queries) GetUserByID added in v0.0.3

func (q *Queries) GetUserByID(ctx context.Context, arg GetUserByIDParams) (GetUserByIDRow, error)

Get users in the same team mapping as the logged-in user when provided another user's ID

func (*Queries) ListUsers added in v0.0.3

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]ListUsersRow, error)

List all users associated with the authorized user and get the total count

func (*Queries) RetrieveUserWithTeamInfoByAPIKEY added in v0.0.3

func (q *Queries) RetrieveUserWithTeamInfoByAPIKEY(ctx context.Context, token string) (RetrieveUserWithTeamInfoByAPIKEYRow, error)

func (*Queries) UpdateUserRole added in v0.0.3

func (q *Queries) UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) error

Update a user role

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RetrieveUserWithTeamInfoByAPIKEYRow added in v0.0.3

type RetrieveUserWithTeamInfoByAPIKEYRow struct {
	Uuid     string      `json:"uuid"`
	Name     pgtype.Text `json:"name"`
	Email    pgtype.Text `json:"email"`
	Name_2   string      `json:"name_2"`
	TeamUuid string      `json:"team_uuid"`
}

type TeamUser added in v0.0.3

type TeamUser struct {
	ID        int32              `json:"id"`
	TeamID    pgtype.Text        `json:"team_id"`
	UserID    pgtype.Text        `json:"user_id"`
	Role      UserRole           `json:"role"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type Teams added in v0.0.3

type Teams struct {
	ID           int32              `json:"id"`
	Uuid         string             `json:"uuid"`
	PersonalTeam pgtype.Bool        `json:"personal_team"`
	Name         string             `json:"name"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

type UpdateUserRoleParams added in v0.0.3

type UpdateUserRoleParams struct {
	Role  UserRole `json:"role"`
	Token string   `json:"token"`
}

type UserRole added in v0.0.3

type UserRole string
const (
	UserRoleAdmin      UserRole = "admin"
	UserRoleMaintainer UserRole = "maintainer"
)

func (*UserRole) Scan added in v0.0.3

func (e *UserRole) Scan(src interface{}) error

type Users added in v0.0.3

type Users struct {
	ID               int32              `json:"id"`
	Uuid             string             `json:"uuid"`
	Name             pgtype.Text        `json:"name"`
	Email            pgtype.Text        `json:"email"`
	EmailVerifiedAt  pgtype.Timestamptz `json:"email_verified_at"`
	Password         pgtype.Text        `json:"password"`
	RememberToken    pgtype.Text        `json:"remember_token"`
	CurrentTeamID    pgtype.Int4        `json:"current_team_id"`
	ProfilePhotoPath pgtype.Text        `json:"profile_photo_path"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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