Added an option to specify demo user, will be created on startup if it does not exist
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/config"
|
||||
@@ -53,6 +54,11 @@ func CreateDefaultUsers(db *gorm.DB, config *config.Config) error {
|
||||
usernames = append(usernames, splittedString[0])
|
||||
usersPasswordMap[splittedString[0]] = splittedString[1]
|
||||
}
|
||||
if !slices.Contains(usernames, config.DemoUsername) {
|
||||
usernames = append(usernames, config.DemoUsername)
|
||||
usersPasswordMap[config.DemoUsername] = ""
|
||||
|
||||
}
|
||||
|
||||
var existingUsers []model.User
|
||||
err := db.Where("name IN ?", usernames).Find(&existingUsers).Error
|
||||
|
||||
Reference in New Issue
Block a user