Compare commits

...

2 Commits

1 changed files with 15 additions and 2 deletions

View File

@ -168,9 +168,16 @@ func Logout(token string) error {
}
func VerifyLoginToken(token string) error {
_, err := jwt.Verify(jwt.HS256, sharedKey, []byte(token), blocklist)
uvt, err := jwt.Decode([]byte(token))
if err != nil {
return err
return ErrInvalidToken
}
var claim jwt.Claims
err = uvt.Claims(&claim)
if err != nil {
return ErrInvalidToken
}
session := model.LoginSession{}
@ -179,5 +186,11 @@ func VerifyLoginToken(token string) error {
return ErrInvalidToken
}
_, err = jwt.Verify(jwt.HS256, sharedKey, []byte(token), blocklist)
if err != nil {
db.Get().Delete(&session)
return err
}
return nil
}