fix(onboarding): could not create user (#848)

fix: onboarding not working
This commit is contained in:
ze0s 2023-04-17 20:56:17 +02:00 committed by GitHub
parent d03561d61c
commit 7f05dd1efd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 182 additions and 130 deletions

View file

@ -43,10 +43,10 @@ func (h releaseHandler) findReleases(w http.ResponseWriter, r *http.Request) {
limitP := r.URL.Query().Get("limit")
limit, err := strconv.Atoi(limitP)
if err != nil && limitP != "" {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusBadRequest, map[string]interface{}{
"code": "BAD_REQUEST_PARAMS",
"message": "limit parameter is invalid",
}, http.StatusBadRequest)
})
return
}
if limit == 0 {
@ -56,10 +56,10 @@ func (h releaseHandler) findReleases(w http.ResponseWriter, r *http.Request) {
offsetP := r.URL.Query().Get("offset")
offset, err := strconv.Atoi(offsetP)
if err != nil && offsetP != "" {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusBadRequest, map[string]interface{}{
"code": "BAD_REQUEST_PARAMS",
"message": "offset parameter is invalid",
}, http.StatusBadRequest)
})
return
}
@ -68,20 +68,20 @@ func (h releaseHandler) findReleases(w http.ResponseWriter, r *http.Request) {
if cursorP != "" {
cursor, err = strconv.Atoi(cursorP)
if err != nil && cursorP != "" {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusBadRequest, map[string]interface{}{
"code": "BAD_REQUEST_PARAMS",
"message": "cursor parameter is invalid",
}, http.StatusBadRequest)
})
}
return
}
u, err := url.Parse(r.URL.String())
if err != nil {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusBadRequest, map[string]interface{}{
"code": "BAD_REQUEST_PARAMS",
"message": "indexer parameter is invalid",
}, http.StatusBadRequest)
})
return
}
vals := u.Query()
@ -104,10 +104,10 @@ func (h releaseHandler) findReleases(w http.ResponseWriter, r *http.Request) {
releases, nextCursor, count, err := h.service.Find(r.Context(), query)
if err != nil {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusInternalServerError, map[string]interface{}{
"code": "INTERNAL_SERVER_ERROR",
"message": err.Error(),
}, http.StatusInternalServerError)
})
return
}
@ -121,17 +121,17 @@ func (h releaseHandler) findReleases(w http.ResponseWriter, r *http.Request) {
Count: count,
}
h.encoder.StatusResponse(r.Context(), w, ret, http.StatusOK)
h.encoder.StatusResponse(w, http.StatusOK, ret)
}
func (h releaseHandler) findRecentReleases(w http.ResponseWriter, r *http.Request) {
releases, err := h.service.FindRecent(r.Context())
if err != nil {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusInternalServerError, map[string]interface{}{
"code": "INTERNAL_SERVER_ERROR",
"message": err.Error(),
}, http.StatusInternalServerError)
})
return
}
@ -141,43 +141,43 @@ func (h releaseHandler) findRecentReleases(w http.ResponseWriter, r *http.Reques
Data: releases,
}
h.encoder.StatusResponse(r.Context(), w, ret, http.StatusOK)
h.encoder.StatusResponse(w, http.StatusOK, ret)
}
func (h releaseHandler) getIndexerOptions(w http.ResponseWriter, r *http.Request) {
stats, err := h.service.GetIndexerOptions(r.Context())
if err != nil {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusInternalServerError, map[string]interface{}{
"code": "INTERNAL_SERVER_ERROR",
"message": err.Error(),
}, http.StatusInternalServerError)
})
return
}
h.encoder.StatusResponse(r.Context(), w, stats, http.StatusOK)
h.encoder.StatusResponse(w, http.StatusOK, stats)
}
func (h releaseHandler) getStats(w http.ResponseWriter, r *http.Request) {
stats, err := h.service.Stats(r.Context())
if err != nil {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusInternalServerError, map[string]interface{}{
"code": "INTERNAL_SERVER_ERROR",
"message": err.Error(),
}, http.StatusInternalServerError)
})
return
}
h.encoder.StatusResponse(r.Context(), w, stats, http.StatusOK)
h.encoder.StatusResponse(w, http.StatusOK, stats)
}
func (h releaseHandler) deleteReleases(w http.ResponseWriter, r *http.Request) {
err := h.service.Delete(r.Context())
if err != nil {
h.encoder.StatusResponse(r.Context(), w, map[string]interface{}{
h.encoder.StatusResponse(w, http.StatusInternalServerError, map[string]interface{}{
"code": "INTERNAL_SERVER_ERROR",
"message": err.Error(),
}, http.StatusInternalServerError)
})
return
}