fix: finish update service endpoint
This commit is contained in:
@ -250,8 +250,8 @@ func (h *AdminHandler) UpdateApiService(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Description == "" {
|
if len(req.Scopes) == 0 {
|
||||||
web.Error(w, "service name is required", http.StatusBadRequest)
|
web.Error(w, "at least 1 scope is required", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,15 +261,25 @@ func (h *AdminHandler) UpdateApiService(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.repo.UpdateApiService(r.Context(), repository.UpdateApiServiceParams{
|
updated, err := h.repo.UpdateApiService(r.Context(), repository.UpdateApiServiceParams{
|
||||||
ClientID: service.ClientID,
|
ClientID: service.ClientID,
|
||||||
Name: ,
|
Name: req.Name,
|
||||||
Description: pgtype.Text{},
|
Description: pgtype.Text{
|
||||||
RedirectUris: []string{},
|
String: req.Description,
|
||||||
Scopes: []string{},
|
Valid: true,
|
||||||
GrantTypes: []string{},
|
},
|
||||||
}); err != nil {
|
RedirectUris: req.RedirectUris,
|
||||||
|
Scopes: req.Scopes,
|
||||||
|
GrantTypes: req.GrantTypes,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
web.Error(w, "failed to update api service", http.StatusInternalServerError)
|
web.Error(w, "failed to update api service", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(w)
|
||||||
|
|
||||||
|
if err := encoder.Encode(NewApiServiceDTO(updated)); err != nil {
|
||||||
|
web.Error(w, "failed to send updated api service", http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user