auth

package
v0.0.0-...-f9eb59d Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 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 AppProvider

type AppProvider interface {
	App(ctx context.Context, appID int) (models.App, error)
}

type Auth

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

func New

func New(
	log *slog.Logger,
	userSaver UserSaver,
	userProvider UserProvider,
	appProvider AppProvider,
	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,
	password string,
	appID int,
) (string, error)

func (*Auth) RegisterNewUser

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

type UserProvider

type UserProvider interface {
	User(ctx context.Context, email string) (models.User, error)
	IsAdmin(ctx context.Context, userID int64) (bool, error)
}

type UserSaver

type UserSaver interface {
	SaveUser(
		ctx context.Context,
		email string,
		passHash []byte,
	) (uid int64, err error)
}

Jump to

Keyboard shortcuts

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