changed registration to have blank username on first load

This commit is contained in:
2026-03-07 12:22:11 +11:00
parent d0c426216d
commit ecae24e73e
2 changed files with 19 additions and 19 deletions

View File

@@ -54,14 +54,14 @@ func Register(
store.ClearRedirectTrack(r, "/register")
if r.Method == "GET" {
renderSafely(authview.RegisterPage(details.DiscordUser.Username), s, r, w)
renderSafely(authview.RegisterPage(""), s, r, w)
return
}
username := r.FormValue("username")
unique := false
var user *db.User
audit := db.NewAudit(r.RemoteAddr, r.UserAgent(), user)
if ok := conn.WithNotifyTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
if ok := conn.WithWriteTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
unique, err = db.IsUnique(ctx, tx, (*db.User)(nil), "username", username)
if err != nil {
return false, errors.Wrap(err, "db.IsUsernameUnique")
@@ -79,6 +79,7 @@ func Register(
}
return true, nil
}); !ok {
throw.InternalServiceError(s, w, r, "Registration failed", err)
return
}
if !unique {