Add simple sanitsation to subscriber name

This commit is contained in:
Kailash Nadh 2018-11-01 21:59:38 +05:30
parent f9c83e6432
commit ad96a4341c
1 changed files with 4 additions and 8 deletions

View File

@ -178,14 +178,12 @@ func handleCreateSubscriber(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
req.Email = strings.ToLower(strings.TrimSpace(req.Email))
// Insert and read ID.
var newID int
err := app.Queries.UpsertSubscriber.Get(&newID,
uuid.NewV4(),
req.Email,
req.Name,
strings.ToLower(strings.TrimSpace(req.Email)),
strings.TrimSpace(req.Name),
req.Status,
req.Attribs,
true,
@ -227,11 +225,9 @@ func handleUpdateSubscriber(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid length for `name`.")
}
req.Email = strings.ToLower(strings.TrimSpace(req.Email))
_, err := app.Queries.UpdateSubscriber.Exec(req.ID,
req.Email,
req.Name,
strings.ToLower(strings.TrimSpace(req.Email)),
strings.TrimSpace(req.Name),
req.Status,
req.Attribs,
req.Lists)