admin

package
v0.0.0-...-ebd6d4f Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	// ID is a short unique identifier.
	ID uint
	// Easily recognisable name for an admin.
	Name string
	// Time the admin was activated.
	// Tokens that are genereted before this time will be invalid.
	// Admins can be reactivated to invalidate old tokens.
	ActivatedAt time.Time
	// Time at which an admin expires.
	// This is by default the expiration date of any token.
	// This can be used to give temporary admin access.
	Expiry time.Time
	// Authorization token that is generated for the admin.
	// This will only be set upon creation.
	AuthorizationToken string
}

An Admin has access to resources that are protected with an AdminToken.

func MakeAdmin

func MakeAdmin(name string, expiry time.Time) Admin

Create a new admin.

func (*Admin) Reactivate

func (a *Admin) Reactivate()

Reactivate admin and invalidate all old tokens.

func (*Admin) SetExpiry

func (a *Admin) SetExpiry(expiry time.Time)

Change the expiry date.

type AdminRepository

type AdminRepository interface {
	Find(admin Admin) (Admin, error)
	GetAll() ([]Admin, error)
	Create(admin Admin) (Admin, error)
	Update(admin Admin) (Admin, error)
	Delete(admin Admin) error
}

An AccountRepository can load, store and delete admins.

Jump to

Keyboard shortcuts

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