session list only shows unexpired normal sessions

This commit is contained in:
MaysWind
2020-12-12 22:23:13 +08:00
parent 75b151da9b
commit 2fa5ed418a
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -46,6 +46,19 @@ func (s *TokenService) GetAllTokensByUid(uid int64) ([]*models.TokenRecord, erro
return tokenRecords, err
}
func (s *TokenService) GetAllUnexpiredMormalTokensByUid(uid int64) ([]*models.TokenRecord, error) {
if uid <= 0 {
return nil, errs.ErrUserIdInvalid
}
now := time.Now().Unix()
var tokenRecords []*models.TokenRecord
err := s.TokenDB(uid).Cols("uid", "user_token_id", "token_type", "user_agent", "created_unix_time", "expired_unix_time").Where("uid=? AND token_type=? AND expired_unix_time>?", uid, core.USER_TOKEN_TYPE_NORMAL, now).OrderBy("created_unix_time desc").Find(&tokenRecords)
return tokenRecords, err
}
func (s *TokenService) ParseToken(c *core.Context) (*jwt.Token, *core.UserTokenClaims, error) {
claims := &core.UserTokenClaims{}