auth

package
v0.0.0-...-184dd24 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCredentials = errors.New("invalid credentials")
)

Functions

This section is empty.

Types

type Auth

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

func New

func New(log *slog.Logger, storage AuthStorage, tokenTTL time.Duration) *Auth

func (*Auth) IsAdmin

func (a *Auth) IsAdmin(ctx context.Context, userID int64) (bool, error)

func (*Auth) Login

func (a *Auth) Login(ctx context.Context, email string, pass string, appID int64) (string, error)

func (*Auth) RegisterNewUser

func (a *Auth) RegisterNewUser(ctx context.Context, email string, pass string) (int64, error)

type AuthStorage

type AuthStorage interface {
	SaveUser(ctx context.Context, email string, passHash []byte) (int64, error)
	User(ctx context.Context, email string) (models.User, error)
	IsAdmin(ctx context.Context, userID int64) (bool, error)
	App(ctx context.Context, appID int64) (models.App, error)
}

Jump to

Keyboard shortcuts

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