diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 5633619..d5e9cd7 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -1700,7 +1700,7 @@ const docTemplate = `{ }, "/auth/register": { "post": { - "description": "Register a new user (defaults to 'profissional' role) with email, password, name and phone", + "description": "Register a new user with email, password, name, phone and role", "consumes": [ "application/json" ], @@ -1814,6 +1814,7 @@ const docTemplate = `{ "required": [ "email", "nome", + "role", "senha" ], "properties": { @@ -1823,6 +1824,10 @@ const docTemplate = `{ "nome": { "type": "string" }, + "role": { + "description": "Role is now required", + "type": "string" + }, "senha": { "type": "string", "minLength": 6 diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 49bd2ba..5b7f506 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -1694,7 +1694,7 @@ }, "/auth/register": { "post": { - "description": "Register a new user (defaults to 'profissional' role) with email, password, name and phone", + "description": "Register a new user with email, password, name, phone and role", "consumes": [ "application/json" ], @@ -1808,6 +1808,7 @@ "required": [ "email", "nome", + "role", "senha" ], "properties": { @@ -1817,6 +1818,10 @@ "nome": { "type": "string" }, + "role": { + "description": "Role is now required", + "type": "string" + }, "senha": { "type": "string", "minLength": 6 diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 5fdafb0..4c4135e 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -42,6 +42,9 @@ definitions: type: string nome: type: string + role: + description: Role is now required + type: string senha: minLength: 6 type: string @@ -50,6 +53,7 @@ definitions: required: - email - nome + - role - senha type: object auth.userResponse: @@ -1434,8 +1438,7 @@ paths: post: consumes: - application/json - description: Register a new user (defaults to 'profissional' role) with email, - password, name and phone + description: Register a new user with email, password, name, phone and role parameters: - description: Register Request in: body diff --git a/backend/internal/auth/handler.go b/backend/internal/auth/handler.go index 74d204a..ec0010d 100644 --- a/backend/internal/auth/handler.go +++ b/backend/internal/auth/handler.go @@ -23,11 +23,12 @@ type registerRequest struct { Senha string `json:"senha" binding:"required,min=6"` Nome string `json:"nome" binding:"required"` Telefone string `json:"telefone"` + Role string `json:"role" binding:"required"` // Role is now required } // Register godoc // @Summary Register a new user -// @Description Register a new user (defaults to 'profissional' role) with email, password, name and phone +// @Description Register a new user with email, password, name, phone and role // @Tags auth // @Accept json // @Produce json @@ -43,17 +44,16 @@ func (h *Handler) Register(c *gin.Context) { return } - // Default simplified registration: Role="profissional" - role := "profissional" - - // Create professional data from input - profData := &profissionais.CreateProfissionalInput{ - Nome: req.Nome, - Whatsapp: &req.Telefone, // Map Telefone to Whatsapp - // FuncaoProfissionalID is left empty intentionally + // Create professional data only if role is appropriate + var profData *profissionais.CreateProfissionalInput + if req.Role == "profissional" || req.Role == "empresa" { + profData = &profissionais.CreateProfissionalInput{ + Nome: req.Nome, + Whatsapp: &req.Telefone, + } } - _, err := h.service.Register(c.Request.Context(), req.Email, req.Senha, role, profData) + _, err := h.service.Register(c.Request.Context(), req.Email, req.Senha, req.Role, profData) if err != nil { if strings.Contains(err.Error(), "duplicate key") { c.JSON(http.StatusConflict, gin.H{"error": "email already registered"}) diff --git a/frontend/components/EventFiltersBar.tsx b/frontend/components/EventFiltersBar.tsx index 052b7cc..9f0ec1e 100644 --- a/frontend/components/EventFiltersBar.tsx +++ b/frontend/components/EventFiltersBar.tsx @@ -82,7 +82,7 @@ export const EventFiltersBar: React.FC = ({ /> - {/* Filtro por Tipo */ + {/* Filtro por Tipo */}