handlers: streamline SignupPost
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-04-19 04:01:03 +02:00
parent 62e038fa3e
commit ff252df692
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -332,16 +332,18 @@ func SignupPost(client *ent.Client) echo.HandlerFunc {
username = uname
if passwd := c.Request().FormValue("password"); passwd != "" {
ctx := context.WithValue(context.Background(), "logger", log)
if u, err := moduser.CreateUser(ctx, client, username, passwd); err != nil {
u, err := moduser.CreateUser(ctx, client, username, passwd)
if err != nil {
// TODO: don't return the error to the user, perhaps based
// on the devel mode.
return echo.NewHTTPError(
http.StatusInternalServerError,
http.StatusText(http.StatusInternalServerError)+" failed to create schema resources "+err.Error(),
)
} else {
log.Infof("successfully registered user '%s': %#v", username, u)
}
log.Infof("successfully registered user '%s': %#v", username, u)
} else {
log.Info("user registration: password was not set, returning to /signup")
}