Documentation ¶
Index ¶
- func AuthenticateUser(ctx context.Context, user *auth.LoginRequest) (string, int64, string, *auth.SimpleUser, error)
- func CheckTokenRevoked(userID, tokenString string) bool
- func CheckUsernameExists(username string) (bool, error)
- func GenerateAccessToken(user *user.User) (string, int64, error)
- func GenerateAvatar(ctx context.Context, ...) (*string, error)
- func GenerateRefreshToken(user *user.User) (string, error)
- func RefreshAccessToken(refreshTokenString string) (string, int64, error)
- func RegisterUser(newUser *user.User) error
- func RevokeRefreshToken(userID, tokenString string) error
- func UpdateUserAvatar(username, avatarUrl string) error
- type Claims
- type Data
- type SmmsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticateUser ¶
func AuthenticateUser(ctx context.Context, user *auth.LoginRequest) (string, int64, string, *auth.SimpleUser, error)
验证用户密码是否正确,返回 JWT令牌,过期时间,刷新令牌,用户基本信息,错误信息
func CheckTokenRevoked ¶
CheckTokenRevoked 检查令牌是否被撤销
func CheckUsernameExists ¶
查询是否username已经存在 只有在数据库查询的时候遇到除了mongo.ErrNoDocuments之外的错误才会返回错误
func GenerateAccessToken ¶
GenerateAccessToken 生成JWT令牌
func GenerateAvatar ¶
func GenerateAvatar(ctx context.Context, imageURL, multiavatarToken, smmsToken, fileName, userid string) (*string, error)
GenerateAvatar 生成用户头像并上传到 SM.MS 图床
func GenerateRefreshToken ¶
GenerateRefreshToken 生成新的刷新令牌
func RefreshAccessToken ¶
RefreshAccessToken 刷新令牌
func RevokeRefreshToken ¶
RevokeToken 使令牌失效
func UpdateUserAvatar ¶
Types ¶
type Claims ¶
type Claims struct { UserId string `json:"user_id"` Username string `json:"username"` jwt.StandardClaims }
Claims 结构体,用于存储JWT声明
func VerifyAccessToken ¶
VerifyAccessToken 验证令牌是否有效,返回声明
func VerifyRefreshToken ¶
VerifyRefreshToken 验证刷新令牌
type Data ¶
type Data struct { FileID int `json:"file_id"` Width int `json:"width"` Height int `json:"height"` Filename string `json:"filename"` Storename string `json:"storename"` Size int `json:"size"` Path string `json:"path"` Hash string `json:"hash"` URL string `json:"url"` Delete string `json:"delete"` Page string `json:"page"` }
Data 定义一个结构体来表示 data 字段
Click to show internal directories.
Click to hide internal directories.