handlers: streamline SignupPost
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
62e038fa3e
commit
ff252df692
@ -332,16 +332,18 @@ func SignupPost(client *ent.Client) echo.HandlerFunc {
|
|||||||
username = uname
|
username = uname
|
||||||
if passwd := c.Request().FormValue("password"); passwd != "" {
|
if passwd := c.Request().FormValue("password"); passwd != "" {
|
||||||
ctx := context.WithValue(context.Background(), "logger", log)
|
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
|
// TODO: don't return the error to the user, perhaps based
|
||||||
// on the devel mode.
|
// on the devel mode.
|
||||||
return echo.NewHTTPError(
|
return echo.NewHTTPError(
|
||||||
http.StatusInternalServerError,
|
http.StatusInternalServerError,
|
||||||
http.StatusText(http.StatusInternalServerError)+" failed to create schema resources "+err.Error(),
|
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 {
|
} else {
|
||||||
log.Info("user registration: password was not set, returning to /signup")
|
log.Info("user registration: password was not set, returning to /signup")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user