This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"smart-search-back/internal/model"
|
||||
"smart-search-back/internal/repository"
|
||||
"smart-search-back/pkg/crypto"
|
||||
"smart-search-back/pkg/errors"
|
||||
"smart-search-back/pkg/jwt"
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/model"
|
||||
"git.techease.ru/Smart-search/smart-search-back/internal/repository"
|
||||
"git.techease.ru/Smart-search/smart-search-back/pkg/crypto"
|
||||
"git.techease.ru/Smart-search/smart-search-back/pkg/errors"
|
||||
"git.techease.ru/Smart-search/smart-search-back/pkg/jwt"
|
||||
)
|
||||
|
||||
type authService struct {
|
||||
@@ -99,9 +99,18 @@ func (s *authService) Validate(ctx context.Context, accessToken string) (int, er
|
||||
return 0, errors.NewBusinessError(errors.AuthInvalidToken, "Invalid user ID in token")
|
||||
}
|
||||
|
||||
isValid, err := s.sessionRepo.IsAccessTokenValid(ctx, accessToken)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if !isValid {
|
||||
return 0, errors.NewBusinessError(errors.AuthInvalidToken, "Token has been revoked or expired")
|
||||
}
|
||||
|
||||
return userID, nil
|
||||
}
|
||||
|
||||
func (s *authService) Logout(ctx context.Context, refreshToken string) error {
|
||||
return s.sessionRepo.Revoke(ctx, refreshToken)
|
||||
func (s *authService) Logout(ctx context.Context, accessToken string) error {
|
||||
return s.sessionRepo.RevokeByAccessToken(ctx, accessToken)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user