auth

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

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateContraint = errors.New("some constraint are duplicate")
	ErrUserNotFound       = errors.New("user not found")
)
View Source
var (
	ErrAuthPwNotMatch = errors.New("authentication password not match")
	ErrUsernameExist  = errors.New("username already exist")
)
View Source
var (
	ErrUsernameRequired = errors.New("password required")
	ErrPasswordRequired = errors.New("password required")
)

Functions

This section is empty.

Types

type AuthApp

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

func NewApp

func NewApp(repository *Repository) *AuthApp

func (*AuthApp) Login

func (a *AuthApp) Login(ctx context.Context, in LoginIn) (out LoginOut)

func (*AuthApp) LoginPost

func (a *AuthApp) LoginPost(session *session.Session) http.HandlerFunc

func (*AuthApp) Register

func (a *AuthApp) Register(ctx context.Context, in RegisterIn) (out RegisterOut)

func (*AuthApp) RegisterPost

func (a *AuthApp) RegisterPost(session *session.Session) http.HandlerFunc

type LoginIn

type LoginIn struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginOut

type LoginOut struct {
	resp.Response
	Res LoginRes
}

type LoginRes

type LoginRes struct {
	IsOfficer bool   `json:"is_officer"`
	Id        string `json:"id"`
}

type RegisterIn

type RegisterIn struct {
	IsOfficer bool   `json:"is_officer"`
	Username  string `json:"username"`
	Password  string `json:"password"`
}

type RegisterOut

type RegisterOut struct {
	resp.Response
	Res RegisterRes
}

type RegisterRes

type RegisterRes struct {
	IsOfficer bool   `json:"is_officer"`
	Id        string `json:"id"`
}

type Repository

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

func NewRepository

func NewRepository(db *pgx.Conn) *Repository

func (*Repository) GetUserByUsername

func (r *Repository) GetUserByUsername(ctx context.Context, username string) (model.User, error)

func (*Repository) InsertUser

func (r *Repository) InsertUser(ctx context.Context, user model.User) (model.User, error)

Jump to

Keyboard shortcuts

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