service

package
v0.0.0-...-fb1bee7 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AccessTokenExpiresIn  = 10 * time.Minute
	RefreshTokenExpiresIn = 120 * time.Minute
)
View Source
var ErrPassportNoAccount = errors.New("no account")

Functions

func PassportWithChangePassword

func PassportWithChangePassword(ctx context.Context, password string, accountId string) error

func PassportWithChangeStatus

func PassportWithChangeStatus(ctx context.Context, status PassportStatus, accountId string) error

func PassportWithExist

func PassportWithExist(ctx context.Context, account string) (bool, error)

func PassportWithRegister

func PassportWithRegister(ctx context.Context, account, password string) (string, error)

func PassportWithRemove

func PassportWithRemove(ctx context.Context, accountId string) error

func TokenWithRevokeByAccountId

func TokenWithRevokeByAccountId(ctx context.Context, id string) error

func TokenWithRevokeByToken

func TokenWithRevokeByToken(ctx context.Context, token Token) error

func TokenWithVerify

func TokenWithVerify(ctx context.Context, token Token) error

Types

type Passport

type Passport struct {
	Id              string    `json:"id"`
	Account         string    `json:"account"`
	Code            string    `json:"code"`
	Email           string    `json:"email"`
	Phone           string    `json:"phone"`
	Status          int32     `json:"status"`
	CreateTimestamp time.Time `json:"create_timestamp"`
}

func PassportWithAuth

func PassportWithAuth(ctx context.Context, method PassportAuthMethod, account, key string) (*Passport, error)

func PassportWithGet

func PassportWithGet(ctx context.Context, account string) (*Passport, error)

type PassportAuthMethod

type PassportAuthMethod int8
const (
	PASSWORD PassportAuthMethod = iota
	SMS
)

type PassportStatus

type PassportStatus int32
const (
	NORMAL PassportStatus = iota
	LOCK
)

type Token

type Token struct {
	AccessToken  string
	TokenType    string
	RefreshToken string

	ExpiresIn int64
}

func TokenWithApply

func TokenWithApply(ctx context.Context, accountId, role string) (*Token, error)

func TokenWithRenew

func TokenWithRenew(ctx context.Context, token string) (*Token, error)

Jump to

Keyboard shortcuts

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