user

package
v0.0.0-...-57b3f38 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package user provides a core business API of a user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

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

Core manages the set of APIs for permit.

func NewCore

func NewCore(logger *slog.Logger, db *sqlx.DB) *Core

NewCore constructs the permit acces api.

func (*Core) APIKeyValidation

func (c *Core) APIKeyValidation(ctx context.Context, apikey string) error

APIKeyValidation hash the API key and checks if this API Key have is authorized.

func (*Core) Create

func (c *Core) Create(ctx context.Context, nu NewUser) (User, error)

Create generates an API key and creates the user. Returns the api key of the user.

func (*Core) DeleteAll

func (c *Core) DeleteAll(ctx context.Context) error

DeleteAll deletes all users.

func (*Core) IsUsersEmpty

func (c *Core) IsUsersEmpty(ctx context.Context) (bool, error)

IsUsersEmpty checks if the table users is empty.

type NewUser

type NewUser struct {
	Name string
}

NewUser contains information needed to create a new user.

type User

type User struct {
	ID          uuid.UUID `json:"user_id"`
	Name        string    `json:"user_name"`
	APIKey      string    `json:"api_key"`
	DateCreated time.Time `json:"date_created"`
}

User represents individual user.

Directories

Path Synopsis
Package userdb contains user related CRUD functionality.
Package userdb contains user related CRUD functionality.

Jump to

Keyboard shortcuts

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