15420d4d89
Partially rewrote the forum permissions system to make it more stable. Moved config.go into it's own package in /config/ Removed Go Git as a dependency. Tweaked the GopherJS pulling. Fixed inserts where all the columns have default values. Reverted a silly tweak I made thinking that mOrder == order. Removed the /common/ hack from the patcher. Fixed a bug where the forum creator would ignore the visiblity value you provided. The tests now work again. Swapped a misplaced fmt.Println with a fmt.Printf. Fixed a bug in the installer where all the table logs would be on one line in the console. Added more logging to the installer.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package install
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"../../query_gen/lib"
|
|
)
|
|
|
|
var adapters = make(map[string]InstallAdapter)
|
|
|
|
type InstallAdapter interface {
|
|
Name() string
|
|
DefaultPort() string
|
|
SetConfig(dbHost string, dbUsername string, dbPassword string, dbName string, dbPort string)
|
|
InitDatabase() error
|
|
TableDefs() error
|
|
InitialData() error
|
|
CreateAdmin() error
|
|
|
|
DBHost() string
|
|
DBUsername() string
|
|
DBPassword() string
|
|
DBName() string
|
|
DBPort() string
|
|
}
|
|
|
|
func Lookup(name string) (InstallAdapter, bool) {
|
|
adap, ok := adapters[name]
|
|
return adap, ok
|
|
}
|
|
|
|
func createAdmin() error {
|
|
fmt.Println("Creating the admin user")
|
|
hashedPassword, salt, err := BcryptGeneratePassword("password")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Build the admin user query
|
|
adminUserStmt, err := qgen.Builder.SimpleInsert("users", "name, password, salt, email, group, is_super_admin, active, createdAt, lastActiveAt, message, last_ip", "'Admin',?,?,'admin@localhost',1,1,1,UTC_TIMESTAMP(),UTC_TIMESTAMP(),'','127.0.0.1'")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Run the admin user query
|
|
_, err = adminUserStmt.Exec(hashedPassword, salt)
|
|
return err
|
|
}
|