users

package
v0.0.0-...-06a4187 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLevel

type AccessLevel int
const (
	Admin     AccessLevel = 1000
	Passenger AccessLevel = 10
)

type RefreshTokenFrom

type RefreshTokenFrom struct {
	RefreshToken string `json:"refresh_token" binding:"required"`
}

func (RefreshTokenFrom) Bind

func (r2 RefreshTokenFrom) Bind(r *http.Request) error

type Token

type Token struct {
	AuthToken    string `json:"auth_token"`
	RefreshToken string `json:"refresh_token"`
}

type User

type User struct {
	ID             int64       `json:"id" db:"id"`
	FirstName      string      `json:"first_name"  db:"first_name"`
	LastName       string      `json:"last_name" db:"last_name"`
	Email          string      `json:"email" db:"email"`
	HomeLocationID null.Int    `json:"home_location_id" db:"home_location_id"`
	WorkLocationID null.Int    `json:"work_location_id" db:"work_location_id"`
	Password       string      `json:"-" db:"password"`
	Access         AccessLevel `json:"-" db:"access_level"`
	LastLogin      null.Time   `json:"last_login" db:"last_login"`
	CreatedAt      time.Time   `json:"created_at" db:"created_at"`
	UpdatedAt      time.Time   `json:"updated_at" db:"updated_at"`
}

type UserLoginForm

type UserLoginForm struct {
	Email    string `json:"email" binding:"required"`
	Password string `json:"password" binding:"required"`
}

func (UserLoginForm) Bind

func (u UserLoginForm) Bind(r *http.Request) error

type UserRegisterForm

type UserRegisterForm struct {
	FirstName      string   `json:"first_name"  binding:"required"`
	LastName       string   `json:"last_name" binding:"required"`
	Email          string   `json:"email" binding:"required"`
	Password       string   `json:"password" binding:"required"`
	HomeLocationID null.Int `json:"home_location_id"`
	WorkLocationID null.Int `json:"work_location_id"`
}

func (UserRegisterForm) Bind

func (u UserRegisterForm) Bind(r *http.Request) error

type UserServiceProvider

type UserServiceProvider interface {
	GetByID(ctx context.Context, id int64) (User, error)
	Login(ctx context.Context, creds *UserLoginForm) (Token, error)
	RefreshToken(token string) (Token, error)
	Signup(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
}

type UserStorer

type UserStorer interface {
	SelectByID(ctx context.Context, id int64) (User, error)
	SelectByEmail(ctx context.Context, email string) (User, error)
	Insert(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
}

Directories

Path Synopsis
delivery
repo

Jump to

Keyboard shortcuts

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