mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-12-03 02:23:16 +00:00
fix: Jwt
This commit is contained in:
@@ -24,6 +24,10 @@ func NewJwt(key string, tokenExpireDuration time.Duration) *Jwt {
|
||||
}
|
||||
|
||||
func (s *Jwt) GenerateToken(userId uint) string {
|
||||
if len(s.Key) == 0 {
|
||||
fmt.Println("jwt key is nil")
|
||||
return ""
|
||||
}
|
||||
t := jwt.NewWithClaims(jwt.SigningMethodHS256,
|
||||
UserClaims{
|
||||
UserId: userId,
|
||||
@@ -33,7 +37,7 @@ func (s *Jwt) GenerateToken(userId uint) string {
|
||||
})
|
||||
token, err := t.SignedString(s.Key)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Printf("jwt token generate error: %v", err)
|
||||
return ""
|
||||
}
|
||||
return token
|
||||
|
||||
Reference in New Issue
Block a user