add service
Some checks failed
Deploy Smart Search Backend / deploy (push) Failing after 1m54s

This commit is contained in:
vallyenfail
2026-01-17 20:41:37 +03:00
parent 635acd13ac
commit e2968722ed
70 changed files with 7542 additions and 463 deletions

View File

@@ -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)
}