Support setting `description` on user registration

pull/463/head
Matt Baer 4 years ago
parent ddc7087d1e
commit 85fb2a952b
  1. 3
      account.go
  2. 4
      app.go
  3. 6
      database.go
  4. 3
      users.go

@ -167,7 +167,7 @@ func signupWithRegistration(app *App, signup userRegistration, w http.ResponseWr
} }
// Create actual user // Create actual user
if err := app.db.CreateUser(app.cfg, u, desiredUsername); err != nil { if err := app.db.CreateUser(app.cfg, u, desiredUsername, signup.Description); err != nil {
return nil, err return nil, err
} }
@ -195,6 +195,7 @@ func signupWithRegistration(app *App, signup userRegistration, w http.ResponseWr
{ {
Alias: signup.Alias, Alias: signup.Alias,
Title: title, Title: title,
Description: signup.Description,
}, },
} }

@ -621,7 +621,7 @@ func DoConfig(app *App, configSections string) {
// Create blog // Create blog
log.Info("Creating user %s...\n", u.Username) log.Info("Creating user %s...\n", u.Username)
err = app.db.CreateUser(app.cfg, u, app.cfg.App.SiteName) err = app.db.CreateUser(app.cfg, u, app.cfg.App.SiteName, "")
if err != nil { if err != nil {
log.Error("Unable to create user: %s", err) log.Error("Unable to create user: %s", err)
os.Exit(1) os.Exit(1)
@ -866,7 +866,7 @@ func CreateUser(apper Apper, username, password string, isAdmin bool) error {
userType = "admin" userType = "admin"
} }
log.Info("Creating %s %s...", userType, usernameDesc) log.Info("Creating %s %s...", userType, usernameDesc)
err = apper.App().db.CreateUser(apper.App().Config(), u, desiredUsername) err = apper.App().db.CreateUser(apper.App().Config(), u, desiredUsername, "")
if err != nil { if err != nil {
return fmt.Errorf("Unable to create user: %s", err) return fmt.Errorf("Unable to create user: %s", err)
} }

@ -51,7 +51,7 @@ var (
) )
type writestore interface { type writestore interface {
CreateUser(*config.Config, *User, string) error CreateUser(*config.Config, *User, string, string) error
UpdateUserEmail(keys *key.Keychain, userID int64, email string) error UpdateUserEmail(keys *key.Keychain, userID int64, email string) error
UpdateEncryptedUserEmail(int64, []byte) error UpdateEncryptedUserEmail(int64, []byte) error
GetUserByID(int64) (*User, error) GetUserByID(int64) (*User, error)
@ -179,7 +179,7 @@ func (db *datastore) dateSub(l int, unit string) string {
} }
// CreateUser creates a new user in the database from the given User, UPDATING it in the process with the user's ID. // CreateUser creates a new user in the database from the given User, UPDATING it in the process with the user's ID.
func (db *datastore) CreateUser(cfg *config.Config, u *User, collectionTitle string) error { func (db *datastore) CreateUser(cfg *config.Config, u *User, collectionTitle string, collectionDesc string) error {
if db.PostIDExists(u.Username) { if db.PostIDExists(u.Username) {
return impart.HTTPError{http.StatusConflict, "Invalid collection name."} return impart.HTTPError{http.StatusConflict, "Invalid collection name."}
} }
@ -213,7 +213,7 @@ func (db *datastore) CreateUser(cfg *config.Config, u *User, collectionTitle str
if collectionTitle == "" { if collectionTitle == "" {
collectionTitle = u.Username collectionTitle = u.Username
} }
res, err = t.Exec("INSERT INTO collections (alias, title, description, privacy, owner_id, view_count) VALUES (?, ?, ?, ?, ?, ?)", u.Username, collectionTitle, "", defaultVisibility(cfg), u.ID, 0) res, err = t.Exec("INSERT INTO collections (alias, title, description, privacy, owner_id, view_count) VALUES (?, ?, ?, ?, ?, ?)", u.Username, collectionTitle, collectionDesc, defaultVisibility(cfg), u.ID, 0)
if err != nil { if err != nil {
t.Rollback() t.Rollback()
if db.isDuplicateKeyErr(err) { if db.isDuplicateKeyErr(err) {

@ -43,6 +43,9 @@ type (
Honeypot string `json:"fullname" schema:"fullname"` Honeypot string `json:"fullname" schema:"fullname"`
Normalize bool `json:"normalize" schema:"normalize"` Normalize bool `json:"normalize" schema:"normalize"`
Signup bool `json:"signup" schema:"signup"` Signup bool `json:"signup" schema:"signup"`
// Feature fields
Description string `json:"description" schema:"description"`
} }
// AuthUser contains information for a newly authenticated user (either // AuthUser contains information for a newly authenticated user (either

Loading…
Cancel
Save