Provide command line variables for initializing an admin user. Previously to get admin access on a fresh install I had to create a user in the web interface (to make sure the password hash/salt is properly setup) then manually change the role in the database to 'admin' using a postgresql client. This was a pain in the ass, and I think there really needs to be an easy way to create the admin user on the initial deployment. This solution fixes this, and adds documentation to the README file on how to use those variables.
This commit is contained in:
parent
defaa2ae0b
commit
f836f40f89
5 changed files with 62 additions and 2 deletions
7
main.go
7
main.go
|
@ -23,6 +23,8 @@ func main() {
|
|||
assetsPath = flag.String("assets", ".", "Path of the assets (templates, css, js, img)")
|
||||
hostname = flag.String("hostname", "xfmro77i3lixucja.onion", "Hostname of the website")
|
||||
loggerConfig = flag.String("logger-conf", "logger.xml", "xml configuration of the logger")
|
||||
setAdminUser = flag.String("set-admin-user", "", "create/update this user to be admin if set-admin-pass is also specified")
|
||||
setAdminPass = flag.String("set-admin-pass", "", "create/update admin user password if set-admin-user is also specified")
|
||||
ro = flag.Bool("ro", false, "read only mode")
|
||||
)
|
||||
flag.Parse()
|
||||
|
@ -40,6 +42,11 @@ func main() {
|
|||
Password: *dbPassword,
|
||||
Name: *dbName,
|
||||
})
|
||||
if err == nil {
|
||||
if *setAdminUser != "" && *setAdminPass != "" {
|
||||
db.SetAdminUser(*setAdminUser, *setAdminPass)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Critical("Problem initializing database: ", err)
|
||||
os.Exit(1)
|
||||
|
|
Reference in a new issue