mirror of
https://github.com/Alexander-D-Karpov/concord.git
synced 2026-03-16 22:04:15 +03:00
27 lines
510 B
Go
27 lines
510 B
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/Alexander-D-Karpov/concord/internal/auth/jwt"
|
|
)
|
|
|
|
type Validator struct {
|
|
jwtManager *jwt.Manager
|
|
}
|
|
|
|
func NewValidator(jwtManager *jwt.Manager) *Validator {
|
|
return &Validator{
|
|
jwtManager: jwtManager,
|
|
}
|
|
}
|
|
|
|
func (v *Validator) ValidateToken(ctx context.Context, token string) (*jwt.Claims, error) {
|
|
claims, err := v.jwtManager.ValidateVoiceToken(token)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("invalid voice token: %w", err)
|
|
}
|
|
return claims, nil
|
|
}
|