From 2ea10939f2893e78e8307c00efabd8f4f195e21a Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 9 Nov 2018 14:51:11 -0500 Subject: [PATCH] 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 --- pages/landing.tmpl | 86 +++++++++++++++++++++++++++++++++++++++++--- unregisteredusers.go | 9 +++++ 2 files changed, 91 insertions(+), 4 deletions(-) diff --git a/pages/landing.tmpl b/pages/landing.tmpl index 397a261..ea72792 100644 --- a/pages/landing.tmpl +++ b/pages/landing.tmpl @@ -50,6 +50,9 @@ tr.subscription { text-align: left; margin: 0.5em 0; } +form dd { + margin: 0; +} {{end}} {{define "content"}} @@ -57,8 +60,8 @@ tr.subscription {
-

{{if .Federation}}Start your blog in the fediverse{{else}}Start your minimalist blog{{end}}

-

Learn more...

+

{{if .Federation}}Start your blog in the fediverse{{else}}Start your blog{{end}}

+

Learn more...

@@ -67,13 +70,13 @@ tr.subscription { {{end}}
-
+
{{ end }} + + + {{end}} diff --git a/unregisteredusers.go b/unregisteredusers.go index 8cd3dec..bf4227b 100644 --- a/unregisteredusers.go +++ b/unregisteredusers.go @@ -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, "/"}