fix: accept legacy login payload
This commit is contained in:
parent
b00d0fe99c
commit
e701b57f6a
2 changed files with 19 additions and 3 deletions
|
|
@ -53,10 +53,24 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
|||
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 == "" {
|
||||
writeError(w, http.StatusBadRequest, errors.New("username is required"))
|
||||
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)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -53,9 +53,11 @@ type registerCompanyTarget struct {
|
|||
}
|
||||
|
||||
type loginRequest struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Identificador string `json:"identificador,omitempty"`
|
||||
Senha string `json:"senha,omitempty"`
|
||||
}
|
||||
|
||||
type forgotPasswordRequest struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue