Преглед на файлове

Support setting `description` on user registration

pull/463/head
Matt Baer преди 2 години
родител
ревизия
85fb2a952b
променени са 4 файла, в които са добавени 12 реда и са изтрити 8 реда
  1. +4
    -3
      account.go
  2. +2
    -2
      app.go
  3. +3
    -3
      database.go
  4. +3
    -0
      users.go

+ 4
- 3
account.go Целия файл

@@ -167,7 +167,7 @@ func signupWithRegistration(app *App, signup userRegistration, w http.ResponseWr
}

// 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
}

@@ -193,8 +193,9 @@ func signupWithRegistration(app *App, signup userRegistration, w http.ResponseWr
}
resUser.Collections = &[]Collection{
{
Alias: signup.Alias,
Title: title,
Alias: signup.Alias,
Title: title,
Description: signup.Description,
},
}



+ 2
- 2
app.go Целия файл

@@ -621,7 +621,7 @@ func DoConfig(app *App, configSections string) {

// Create blog
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 {
log.Error("Unable to create user: %s", err)
os.Exit(1)
@@ -866,7 +866,7 @@ func CreateUser(apper Apper, username, password string, isAdmin bool) error {
userType = "admin"
}
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 {
return fmt.Errorf("Unable to create user: %s", err)
}


+ 3
- 3
database.go Целия файл

@@ -51,7 +51,7 @@ var (
)

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
UpdateEncryptedUserEmail(int64, []byte) 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.
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) {
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 == "" {
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 {
t.Rollback()
if db.isDuplicateKeyErr(err) {


+ 3
- 0
users.go Целия файл

@@ -43,6 +43,9 @@ type (
Honeypot string `json:"fullname" schema:"fullname"`
Normalize bool `json:"normalize" schema:"normalize"`
Signup bool `json:"signup" schema:"signup"`

// Feature fields
Description string `json:"description" schema:"description"`
}

// AuthUser contains information for a newly authenticated user (either


Зареждане…
Отказ
Запис