Improve sign up

- Add server-side validation
- Normalize usernames
- Check username existence when signing up
- Tailor UI to whether federation is enabled or not
- Return user to form and show errors on sign up
This commit is contained in:
Matt Baer
2018-11-09 14:51:11 -05:00
parent 3609e8065b
commit 2ea10939f2
2 changed files with 91 additions and 4 deletions

View File

@@ -34,9 +34,18 @@ func handleWebSignup(app *app, w http.ResponseWriter, r *http.Request) error {
}
}
ur.Web = true
ur.Normalize = true
_, err := signupWithRegistration(app, ur, w, r)
if err != nil {
if err, ok := err.(impart.HTTPError); ok {
session, _ := app.sessionStore.Get(r, cookieName)
if session != nil {
session.AddFlash(err.Message)
session.Save(r, w)
return impart.HTTPError{http.StatusFound, "/"}
}
}
return err
}
return impart.HTTPError{http.StatusFound, "/"}