Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LibSet = wire.NewSet(NewJwtService, NewUserService)
LibSet 服务providers
Functions ¶
This section is empty.
Types ¶
type AppClaims ¶
type AppClaims struct { IsAdmin bool `json:"isadmin"` jwt.RegisteredClaims }
AppClaims 自定义claims
type JwtService ¶
JwtAuth 提供jwt相关服务
func NewJwtService ¶
func NewJwtService(cfg *conf.Config, redis *redis.Client) *JwtService
func (*JwtService) GenToken ¶
func (s *JwtService) GenToken(iss string, isAdmin bool, user JwtUser) (*TokenOutput, error)
GenToken 创建token
func (*JwtService) IsInBlackList ¶
func (s *JwtService) IsInBlackList(tokenStr string) bool
IsInBlackList 查询token是否在黑名单中
func (*JwtService) JoinBlackList ¶
func (s *JwtService) JoinBlackList(tokenStr string) error
JoinBlackList 将token加入黑名单
func (*JwtService) RequestAuth ¶
func (s *JwtService) RequestAuth(iss string, authStr string) (*AppClaims, *jwt.Token, error)
RequestAuth 请求头jwt认证
type Login ¶
type Login struct { Phone string `form:"phone" json:"phone" binding:"required,len=11,number"` Password string `form:"password" json:"password" binding:"required,gte=6"` IsAdmin bool `form:"category" json:"category" default:"false"` }
Login 登录信息
func (Login) GetMessages ¶
func (login Login) GetMessages() request.ValidatorMessages
GetMessages 实现request.Validator接口
type Register ¶
type Register struct { Name string `form:"name" json:"name" binding:"required"` // user name Phone string `form:"phone" json:"phone" binding:"required,len=11,number"` // phone Password string `form:"password" json:"password" binding:"required,gte=6"` // password IsAdmin bool `form:"category" json:"category" default:"false"` }
Register 注册信息
func (Register) GetMessages ¶
func (register Register) GetMessages() request.ValidatorMessages
GetMessages 实现request.Validator接口
type TokenOutput ¶
type TokenOutput struct { Token string `json:"token"` Expires int `json:"expires"` Type string `json:"type"` }
TokenOutput token输出格式
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService 提供user相关服务
func (*UserService) GetUserInfo ¶
func (s *UserService) GetUserInfo(id string, isAdmin bool) (JwtUser, error)
GetUserInfo 获取单个用户信息
Click to show internal directories.
Click to hide internal directories.