bf851bd9fc
Added support for dyntmpl to the template system. The Account Dashboard now sort of uses dyntmpl, more work needed here. Renamed the pre_render_view_topic hook to pre_render_topic. Added the GetCurrentLangPack() function. Added the alerts_no_new_alerts phrase. Added the account_level_list phrase. Refactored the route rename logic in the patcher to cut down on the amount of boilerplate. Added more route renames to the patcher. You will need to run the patcher / updater in this commit.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package install
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Azareal/Gosora/query_gen"
|
|
)
|
|
|
|
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, lastLiked, oldestItemLikedCreatedAt, message, last_ip", "'Admin',?,?,'admin@localhost',1,1,1,UTC_TIMESTAMP(),UTC_TIMESTAMP(),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
|
|
}
|