auth

package
v0.0.0-...-2b4ca68 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB)

Types

type FailedLoginAttemp

type FailedLoginAttemp struct {
	ID        string `gorm:"type:uuid;primarykey"`
	IPAddress string `gorm:"type:varchar(32);not null;column:ip_address"`
	CreatedAt time.Time
}

type Repository

type Repository interface {
	CreateUser(user *User) error
	GetUser(user *User) (*User, error)
	Save(obj interface{})
	CreateFailedLoginAttempt(attempt *FailedLoginAttemp) error
	GetFailedLoginAttempts(ipAddress string) ([]*FailedLoginAttemp, error)
}

type Service

type Service interface {
	Register(username, password string) (*User, error)
	Login(username, password, ipAddress string) (*User, error)
	GetUserByID(id string) (*User, error)
	GenerateOTP(user *User) (string, string, error)
	ValidateOTP(code string, user *User) error
}

func NewService

func NewService(r Repository) Service

type User

type User struct {
	gorm.Model
	ID           string `gorm:"type:uuid;primarykey"`
	Username     string `gorm:"type:varchar(32);unique_index"`
	PasswordHash string `gorm:"not null"`
	Token        string `gorm:"-"`
	SecretKey    string
}

Jump to

Keyboard shortcuts

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