fixed initial user
Some checks failed
Build and Push Docker Image / Build image (push) Has been cancelled

This commit is contained in:
2025-04-09 03:15:38 +03:00
parent 8747c308e5
commit 8ac960102a
5 changed files with 40 additions and 39 deletions

View File

@@ -1,11 +1,8 @@
package factories
import (
"context"
"errors"
"log"
"sync"
"time"
"git.acooldomain.co/server-manager/backend/dbhandler"
"git.acooldomain.co/server-manager/backend/dbhandler/mongo"
@@ -136,21 +133,6 @@ func GetUserPassAuthDbHandler(config models.UserPassAuthConfig) (dbhandler.UserP
}
userPassAuthDbHandlers[key] = handler
ctx, cancel := context.WithTimeoutCause(context.Background(), 5*time.Second, errors.New("Timeout"))
defer cancel()
if config.InitialUser == nil {
return handler, nil
}
count, _ := handler.CountUsers(ctx)
if count == 0 {
log.Printf("Trying to create user %#v\n", config.InitialUser)
err := handler.CreateUser(ctx, config.InitialUser.Username, config.InitialUser.Password, models.Admin, config.InitialUser.Email, 10)
if err != nil {
log.Printf("Failed to create initial user %e\n", err)
}
}
return handler, nil
}