|
|
@@ -155,16 +155,16 @@ func (db *datastore) dateSub(l int, unit string) string { |
|
|
|
} |
|
|
|
|
|
|
|
func (db *datastore) CreateUser(u *User, collectionTitle string) error { |
|
|
|
if db.PostIDExists(u.Username) { |
|
|
|
return impart.HTTPError{http.StatusConflict, "Invalid collection name."} |
|
|
|
} |
|
|
|
|
|
|
|
// New users get a `users` and `collections` row. |
|
|
|
t, err := db.Begin() |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
if db.PostIDExists(u.Username) { |
|
|
|
return impart.HTTPError{http.StatusConflict, "Invalid collection name."} |
|
|
|
} |
|
|
|
|
|
|
|
// 1. Add to `users` table |
|
|
|
// NOTE: Assumes User's Password is already hashed! |
|
|
|
res, err := t.Exec("INSERT INTO users (username, password, email) VALUES (?, ?, ?)", u.Username, u.HashedPass, u.Email) |
|
|
|