fix: accept legacy login payload

This commit is contained in:
Tiago Yamamoto 2026-03-04 12:33:49 -06:00
parent b00d0fe99c
commit e701b57f6a
2 changed files with 19 additions and 3 deletions

View file

@ -53,10 +53,24 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
return return
} }
if req.Username == "" {
req.Username = req.Identificador
}
if req.Username == "" {
req.Username = req.Email
}
if req.Password == "" {
req.Password = req.Senha
}
if req.Username == "" { if req.Username == "" {
writeError(w, http.StatusBadRequest, errors.New("username is required")) writeError(w, http.StatusBadRequest, errors.New("username is required"))
return return
} }
if req.Password == "" {
writeError(w, http.StatusBadRequest, errors.New("password is required"))
return
}
token, exp, err := h.svc.Login(r.Context(), req.Username, req.Password) token, exp, err := h.svc.Login(r.Context(), req.Username, req.Password)
if err != nil { if err != nil {

View file

@ -55,7 +55,9 @@ type registerCompanyTarget struct {
type loginRequest struct { type loginRequest struct {
Username string `json:"username,omitempty"` Username string `json:"username,omitempty"`
Email string `json:"email,omitempty"` Email string `json:"email,omitempty"`
Password string `json:"password"` Password string `json:"password,omitempty"`
Identificador string `json:"identificador,omitempty"`
Senha string `json:"senha,omitempty"`
} }
type forgotPasswordRequest struct { type forgotPasswordRequest struct {