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:
endangered 2019-11-25 06:58:44 +09:30
parent defaa2ae0b
commit f836f40f89
5 changed files with 62 additions and 2 deletions

View file

@ -19,6 +19,7 @@ type DB interface {
IsBookActive(id string) bool
AddUser(name string, pass string) error
AddRawUser(name string, hpass []byte, salt []byte, role string) error
SetAdminUser(name string, pass string) error
GetRole(name string) (string, error)
SetPassword(name string, pass string) error
SetRole(name, role string) error
@ -140,6 +141,8 @@ CREATE INDEX IF NOT EXISTS books_lang_idx ON books (lang);
CREATE INDEX IF NOT EXISTS books_isbn_idx ON books (isbn);
CREATE INDEX IF NOT EXISTS books_active_idx ON books (active);
-- Books trigram indexes
CREATE INDEX IF NOT EXISTS books_title_idx ON books USING GIN (title gin_trgm_ops);
CREATE INDEX IF NOT EXISTS books_contributor_idx ON books USING GIN (contributor gin_trgm_ops);