refactor: разделил приложение на domain application adapters и HTTP DTO

This commit is contained in:
2026-10-20 21:44:59 +03:00
parent 13ee5a0e56
commit 3f69970b05
59 changed files with 1324 additions and 1087 deletions
+6 -10
View File
@@ -7,8 +7,6 @@ import (
"strings"
"mtusi2026lab3/internal/domain"
"mtusi2026lab3/internal/security"
"mtusi2026lab3/internal/store"
"mtusi2026lab3/internal/transport/http/response"
)
@@ -20,10 +18,10 @@ const (
)
type SessionAuthenticator interface {
GetUserBySession(
Authenticate(
ctx context.Context,
tokenHash []byte,
) (domain.User, error)
token string,
) (domain.User, []byte, error)
}
func RequireAuth(
@@ -39,13 +37,11 @@ func RequireAuth(
return
}
tokenHash := security.HashSessionToken(token)
user, err := authenticator.GetUserBySession(
user, tokenHash, err := authenticator.Authenticate(
r.Context(),
tokenHash,
token,
)
if errors.Is(err, store.ErrNotFound) {
if errors.Is(err, domain.ErrNotFound) {
writeBearerUnauthorized(w, requestID)
return
}