auth

package
v0.0.0-...-e05a182 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJWTInvalid = "JWT invalid"
	ErrQueryUser  = "ไม่สามารถค้นหาผู้ใช้ได้"
	ErrCreateUser = "ไม่สามารถสร้างผู้ใช้ได้"
)

Functions

func RouteRegister

func RouteRegister(e *echo.Echo, db *gorm.DB, ce *casbin.Enforcer)

Types

type Auth

type Auth struct {
	AccessToken           string
	AccessTokenExpiresIn  int64
	RefreshToken          string
	RefreshTokenExpiresIn int64
	AccessTokenUUID       string
	RefreshTokenUUID      string
}

type Handler

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

func NewHandler

func NewHandler(repo *Repo) *Handler

func (*Handler) GetProfile

func (h *Handler) GetProfile(c echo.Context) error

func (*Handler) Login

func (h *Handler) Login(c echo.Context) error

func (*Handler) Register

func (h *Handler) Register(c echo.Context) error

type History

type History struct {
	CreatedAt time.Time `json:"loginTime"`
	UserID    string    `json:"userId"`
	Name      string    `json:"name"`
}

type Repo

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

func NewRepo

func NewRepo(db *gorm.DB) *Repo

func (*Repo) CreateLog

func (r *Repo) CreateLog(h *History) error

func (*Repo) CreateUser

func (r *Repo) CreateUser(u *User) error

func (*Repo) GetUserByEmail

func (r *Repo) GetUserByEmail(email string) (*User, error)

func (*Repo) GetUserByID

func (r *Repo) GetUserByID(id string) (*User, error)

func (*Repo) StoreJWT

func (r *Repo) StoreJWT(id string, a *Auth) error

type User

type User struct {
	ID       string
	Name     string
	Email    string
	Password string
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *sqlx.Tx) (err error)

func (*User) ComparePassword

func (u *User) ComparePassword(hash string) error

func (*User) GenAuthToken

func (u *User) GenAuthToken() (*Auth, error)

Jump to

Keyboard shortcuts

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