Skip to content

Commit

Permalink
fix api response codes if user is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Dec 27, 2023
1 parent 1935b0e commit 388dfcb
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,7 @@ func (svc *Service) AppsShowHandler(c echo.Context) error {
})
}
if user == nil {
return c.JSON(http.StatusBadRequest, ErrorResponse{
Error: true,
Code: 8,
Message: "User does not exist",
})
return c.NoContent(http.StatusUnauthorized)
}

app := App{}
Expand Down Expand Up @@ -236,11 +232,7 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error {
})
}
if user == nil {
return c.JSON(http.StatusBadRequest, ErrorResponse{
Error: true,
Code: 8,
Message: "User does not exist",
})
return c.NoContent(http.StatusUnauthorized)
}

name := c.FormValue("name")
Expand Down Expand Up @@ -367,16 +359,12 @@ func (svc *Service) AppsDeleteHandler(c echo.Context) error {
return err
}
if user == nil {
return c.JSON(http.StatusBadRequest, ErrorResponse{
Error: true,
Code: 8,
Message: "User does not exist",
})
return c.NoContent(http.StatusUnauthorized)
}
app := App{}
svc.db.Where("user_id = ? AND nostr_pubkey = ?", user.ID, c.Param("pubkey")).First(&app)
svc.db.Delete(&app)
return c.JSON(http.StatusOK, "App deleted successfully")
return c.NoContent(http.StatusNoContent)
}

func (svc *Service) LogoutHandler(c echo.Context) error {
Expand Down

0 comments on commit 388dfcb

Please sign in to comment.