feat: versão 1.5 - CRM Beta com leads, funis, campanhas e portal do cliente
This commit is contained in:
42
backend/internal/domain/auth_unified.go
Normal file
42
backend/internal/domain/auth_unified.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package domain
|
||||
|
||||
import "github.com/golang-jwt/jwt/v5"
|
||||
|
||||
// UserType representa os diferentes tipos de usuários do sistema
|
||||
type UserType string
|
||||
|
||||
const (
|
||||
UserTypeAgency UserType = "agency_user" // Usuários das agências (admin, colaborador)
|
||||
UserTypeCustomer UserType = "customer" // Clientes do CRM
|
||||
// SUPERADMIN usa endpoint próprio /api/admin/*, não usa autenticação unificada
|
||||
)
|
||||
|
||||
// UnifiedClaims representa as claims do JWT unificado
|
||||
type UnifiedClaims struct {
|
||||
UserID string `json:"user_id"` // ID do usuário (user.id ou customer.id)
|
||||
UserType UserType `json:"user_type"` // Tipo de usuário
|
||||
TenantID string `json:"tenant_id,omitempty"` // ID do tenant (agência)
|
||||
Email string `json:"email"` // Email do usuário
|
||||
Role string `json:"role,omitempty"` // Role (para agency_user: ADMIN_AGENCIA, CLIENTE)
|
||||
AgencyRole string `json:"agency_role,omitempty"` // Agency role (owner ou collaborator)
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
// UnifiedLoginRequest representa uma requisição de login unificada
|
||||
type UnifiedLoginRequest struct {
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// UnifiedLoginResponse representa a resposta de login unificada
|
||||
type UnifiedLoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
UserType UserType `json:"user_type"`
|
||||
UserID string `json:"user_id"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role,omitempty"` // Apenas para agency_user
|
||||
AgencyRole string `json:"agency_role,omitempty"` // owner ou collaborator
|
||||
TenantID string `json:"tenant_id,omitempty"` // ID do tenant
|
||||
Subdomain string `json:"subdomain,omitempty"` // Subdomínio da agência
|
||||
}
|
||||
Reference in New Issue
Block a user