feat(identity): add server sessions and audited mail recovery

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 11:03:46 +03:00
1 parent 20c03288d6
commit 4ee53d9a74
58 files changed
+5359 -567

No files matched your search

@@ -0,0 +1,37 @@
package v1
import (
"context"
"lincodex/backend/internal/adapter/primary/http/api"
"lincodex/backend/internal/domain"
)
func (handler *Handler) GetCurrentAccount(ctx context.Context) (api.GetCurrentAccountRes, error) {
if handler.identity == nil || handler.identity.sessions == nil {
return handler.UnimplementedHandler.GetCurrentAccount(ctx)
}
return handler.identity.GetCurrentAccount(ctx)
}
func (handler *IdentityHandler) GetCurrentAccount(ctx context.Context) (api.GetCurrentAccountRes, error) {
session, ok := sessionFromContext(ctx)
if !ok || !session.EmailVerified {
return unauthenticatedProblemResponse(ctx), nil
}
return &api.AccountHeaders{
CacheControl: api.CacheControlNoStoreNoStore,
Response: accountFromUser(session.User),
}, nil
}
func accountFromUser(user domain.User) api.Account {
return api.Account{
ID: user.ID,
Email: api.EmailAddress(user.Email.Address()),
EmailVerified: user.EmailVerified(),
Scenario: api.AccountScenario(user.Scenario),
OnboardingStep: api.OnboardingStep(user.OnboardingStep),
CreatedAt: api.Timestamp(user.CreatedAt),
}
}