mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
major package structure refactoring
This commit is contained in:
parent
7b8cec9a6c
commit
cf58f8164d
73 changed files with 549 additions and 389 deletions
|
@ -18,7 +18,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/utility"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/web"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ func Check(Db *sqlx.DB, connectionString string) bool {
|
|||
web.SiteMode = web.SiteModeBadDB
|
||||
return false
|
||||
}
|
||||
defer utility.Close(rows)
|
||||
defer streamutil.Close(rows)
|
||||
var version, dbComment, charset, collation string
|
||||
if rows.Next() {
|
||||
err = rows.Scan(&version, &dbComment, &charset, &collation)
|
||||
|
|
|
@ -20,7 +20,8 @@ import (
|
|||
|
||||
"github.com/documize/community/core/api/util"
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/utility"
|
||||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/core/web"
|
||||
)
|
||||
|
||||
|
@ -126,7 +127,7 @@ func Create(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err = setupAccount(details, util.GenerateSalt())
|
||||
err = setupAccount(details, secrets.GenerateSalt())
|
||||
if err != nil {
|
||||
log.Error("database.Create()", err)
|
||||
return
|
||||
|
@ -152,8 +153,8 @@ type onboardRequest struct {
|
|||
// Once done, they can then login and use Documize.
|
||||
func setupAccount(completion onboardRequest, serial string) (err error) {
|
||||
//accountTitle := "This is where you will find documentation for your all projects. You can customize this message from the settings screen."
|
||||
salt := util.GenerateSalt()
|
||||
password := util.GeneratePassword(completion.Password, salt)
|
||||
salt := secrets.GenerateSalt()
|
||||
password := secrets.GeneratePassword(completion.Password, salt)
|
||||
|
||||
// Allocate organization to the user.
|
||||
orgID := util.UniqueID()
|
||||
|
@ -170,7 +171,7 @@ func setupAccount(completion onboardRequest, serial string) (err error) {
|
|||
userID := util.UniqueID()
|
||||
|
||||
sql = fmt.Sprintf("insert into user (refid, firstname, lastname, email, initials, salt, password, global) values (\"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", 1)",
|
||||
userID, completion.Firstname, completion.Lastname, completion.Email, utility.MakeInitials(completion.Firstname, completion.Lastname), salt, password)
|
||||
userID, completion.Firstname, completion.Lastname, completion.Email, stringutil.MakeInitials(completion.Firstname, completion.Lastname), salt, password)
|
||||
_, err = runSQL(sql)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -22,11 +22,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/utility"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/web"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
const migrationsDir = "bindata/scripts"
|
||||
|
@ -170,7 +169,7 @@ func getLastMigration(tx *sqlx.Tx) (lastMigration string, err error) {
|
|||
var stmt *sql.Stmt
|
||||
stmt, err = tx.Prepare("SELECT JSON_EXTRACT(`config`,'$.database') FROM `config` WHERE `key` = 'META';")
|
||||
if err == nil {
|
||||
defer utility.Close(stmt)
|
||||
defer streamutil.Close(stmt)
|
||||
var item = make([]uint8, 0)
|
||||
|
||||
row := stmt.QueryRow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue