Prevent crashing when trying to register with an empty payload

This commit is contained in:
kolaente 2020-06-21 20:54:46 +02:00
parent bfc4dd05ed
commit 150c3f032c
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -45,6 +45,9 @@ func RegisterUser(c echo.Context) error {
if err := c.Bind(&datUser); err != nil { if err := c.Bind(&datUser); err != nil {
return c.JSON(http.StatusBadRequest, models.Message{"No or invalid user model provided."}) return c.JSON(http.StatusBadRequest, models.Message{"No or invalid user model provided."})
} }
if datUser == nil {
return c.JSON(http.StatusBadRequest, models.Message{"No or invalid user model provided."})
}
// Insert the user // Insert the user
newUser, err := user.CreateUser(datUser.APIFormat()) newUser, err := user.CreateUser(datUser.APIFormat())