users

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(secretKey string, claims jwt.Claims) (string, error)

创建一个token

func GetRegisterToken

func GetRegisterToken(secretKey string, t time.Time, seconds int64, RejType, Note string, Code int64) (string, error)

func ParseToken

func ParseToken(claim jwt.Claims, tokenString string, secretKey string) error

解析 token

func ParseTokenWithFunc

func ParseTokenWithFunc(claim jwt.Claims, tokenString string, f jwt.Keyfunc) error

func RefreshLoginToken

func RefreshLoginToken(tokenString string, secretKey string, AccessExpire int64) (string, error)

更新token

Types

type LoginClaims

type LoginClaims struct {
	UserID   int64 `json:",string"`
	AppCode  string
	DeviceID string `json:""`
	jwt.RegisteredClaims
}

Custom claims structure

func GetLoginJwtToken

func GetLoginJwtToken(secretKey string, t time.Time, userID int64, appCode string, id string, deviceID string) (string, LoginClaims, error)

type OpenClaims

type OpenClaims struct {
	UserID     int64  `json:"userID,string"` //账号
	TenantCode string `json:"tenantCode"`
	Code       string `json:"code"`
	jwt.RegisteredClaims
}

Custom claims structure

type RegType

type RegType = string
const (
	RegEmail      RegType = "email"      //邮箱
	RegPhone      RegType = "phone"      //手机号
	RegWxOpen     RegType = "wxOpen"     //微信开放平台登录
	RegWxIn       RegType = "wxIn"       //微信内登录
	RegWxMiniP    RegType = "wxMiniP"    //微信小程序
	RegWxOfficial RegType = "wxOfficial" //微信公众号登录
	RegDingApp    RegType = "dingApp"    //钉钉应用(包含小程序,h5等方式)
	RegPwd        RegType = "pwd"        //账号密码注册
	RegGoogle     RegType = "google"     //google
	RegGithub     RegType = "github"     //github
	RegHuawei     RegType = "huawei"     //华为
	RegJwt        RegType = "jwt"        //第三方jwt加密登录
)

phone 手机号 wxOpen 微信开放平台 wxIn 微信内 wxMiniP 微信小程序 pwd 账号密码

type RegisterClaims

type RegisterClaims struct {
	RejType string `json:",string"` //注册方式:	phone手机号注册 wxopen 微信开放平台登录 wxin 微信内登录 wxminip 微信小程序 pwd 账号密码注册
	Note    string //手机号 微信unionid 用户名
	Code    int64  //账密注册时的密码
	jwt.RegisteredClaims
}

Custom claims structure

type UserInfo

type UserInfo struct {
	UserID      int64 `json:",string"`
	LastTokenID string
	Account     string //账号
	RoleIDs     []int64
	RoleCodes   []string
	TenantCode  string `json:",string"`
	IsAdmin     int64
	IsAllData   int64
}

type UserInfoType

type UserInfoType uint8
const (
	Uid        UserInfoType = iota //用户UID
	InviterUid                     //邀请人用户id
	UserName                       //用户登录名
	GroupId                        //用户组id
	Email                          //邮箱
	Phone                          //手机号
	Wechat                         //微信
	InfoMax                        //结束
	AuthId                         //权限id
)

func GetLoginNameType

func GetLoginNameType(userName string) UserInfoType

type UserStatus

type UserStatus = int64
const (
	NotRegisterStatus UserStatus = iota //未注册完成状态只注册了第一步
	NormalStatus                        //正常状态
)

Jump to

Keyboard shortcuts

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