auth

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EXP_PATTERN = time.Hour
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Client *sqlx.DB
}

func New

func New(client *sqlx.DB) *Auth

func (*Auth) Create

func (y *Auth) Create(u AuthCreateRequest) (uid string, devm string, id int, err error)

func (*Auth) EnsureSingleSession

func (y *Auth) EnsureSingleSession(id int)

func (*Auth) FindAll

func (y *Auth) FindAll(page, limit int) (res []AuthResponse, err error)

func (*Auth) FindById

func (y *Auth) FindById(id int) (res AuthResponse, err error)

func (*Auth) FindByToken

func (y *Auth) FindByToken(token string) (res AuthAndUserResponse, err error)

func (*Auth) FindByUserId

func (y *Auth) FindByUserId(id int) (output *AuthFindStruct, err error)

func (*Auth) FindByUserIdAndActive

func (y *Auth) FindByUserIdAndActive(id int) (output []AuthResponse, err error)

func (*Auth) FindByUserIdAndActiveWithUserData

func (y *Auth) FindByUserIdAndActiveWithUserData(id int) (output *AuthFindStruct, err error)

func (*Auth) UpdateStatus

func (y *Auth) UpdateStatus(id int, status bool) (err error)

type AuthAndUserResponse

type AuthAndUserResponse struct {
	ID     int    `json:"-" db:"id"`
	UserId int    `json:"-" db:"user_id"`
	Token  string `json:"-" db:"token"`
	Exp    int64  `json:"-" db:"exp"`
	Iat    int64  `json:"-" db:"iat"`
	Status bool   `json:"-" db:"status"`
	users.UserResponse
}

type AuthCreateRequest

type AuthCreateRequest struct {
	UserId int    `json:"user_id" db:"user_id"`
	Token  string `json:"token" db:"token"`
	Exp    int64  `json:"exp" db:"exp"`
}

type AuthFindStruct

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

func (*AuthFindStruct) First

func (*AuthFindStruct) Get

func (*AuthFindStruct) Last

type AuthResponse

type AuthResponse struct {
	ID     int    `json:"session_id" db:"id"`
	UserId int    `json:"user_identity" db:"user_id"`
	Token  string `json:"session_token" db:"token"`
	Exp    int64  `json:"exp" db:"exp"`
	Iat    int64  `json:"iat" db:"iat"`
	Status bool   `json:"status" db:"status"`
}

Jump to

Keyboard shortcuts

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