auth

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: GPL-2.0 Imports: 8 Imported by: 2

README

auth

authentication library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternal          = errors.New("internal error")
	ErrWrongCredentials  = errors.New("wrong credentials")
	ErrUserAlreadyExists = errors.New("user already exists")
	ErrInvalidUserName   = errors.New("invalid username")
	ErrExpiredSession    = errors.New("session is expired")
	ErrSessionNotFound   = errors.New("not signed in")
)

Functions

This section is empty.

Types

type Auth

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

func NewAuth

func NewAuth(db *db.DB) *Auth

func (*Auth) SignIn

func (a *Auth) SignIn(name, code string, duration time.Duration) error

func (*Auth) SignOut

func (a *Auth) SignOut(name, code string) error

func (*Auth) SignUp

func (a *Auth) SignUp(name, code string) error

func (*Auth) ValidateSession

func (a *Auth) ValidateSession(name, code string) error

type Session

type Session struct {
	db.Model
	Name      string `gorm:"unique"`
	ExpiredAt time.Time
}

type User

type User struct {
	db.Model
	Name string
	Code string
}

Jump to

Keyboard shortcuts

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