Merge pull request #770 from writefreely/passwordless-db

Support using MySQL without a password
This commit is contained in:
Matt Baer 2023-09-21 18:16:25 -04:00 committed by GitHub
commit 2986f83121
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

4
app.go
View file

@ -569,8 +569,8 @@ func (app *App) InitDecoder() {
// tests the connection. // tests the connection.
func ConnectToDatabase(app *App) error { func ConnectToDatabase(app *App) error {
// Check database configuration // Check database configuration
if app.cfg.Database.Type == driverMySQL && (app.cfg.Database.User == "" || app.cfg.Database.Password == "") { if app.cfg.Database.Type == driverMySQL && app.cfg.Database.User == "" {
return fmt.Errorf("Database user or password not set.") return fmt.Errorf("Database user not set.")
} }
if app.cfg.Database.Host == "" { if app.cfg.Database.Host == "" {
app.cfg.Database.Host = "localhost" app.cfg.Database.Host = "localhost"