Add admin passwd env
This commit is contained in:
@@ -8,6 +8,8 @@ services:
|
||||
- /root/send-it/uploads:/app/uploads
|
||||
- /root/send-it/data:/app/data
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
ADMIN_PASSWORD: ""
|
||||
|
||||
networks:
|
||||
scoobydoo:
|
||||
|
||||
@@ -105,9 +105,16 @@ func ensureAdmin() {
|
||||
var count int64
|
||||
db.Model(&User{}).Where("username = ?", "admin").Count(&count)
|
||||
|
||||
password := os.Getenv("ADMIN_PASSWORD")
|
||||
if password == "" {
|
||||
log.Println("WARNING: ADMIN_PASSWORD not set, using default password")
|
||||
log.Println("MAKING NO ADMIN ACCOUNT")
|
||||
return
|
||||
}
|
||||
|
||||
if count == 0 {
|
||||
hash, _ := bcrypt.GenerateFromPassword(
|
||||
[]byte("change_this_password"),
|
||||
[]byte(password),
|
||||
bcrypt.DefaultCost,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user