fixed initial user
Some checks failed
Build and Push Docker Image / Build image (push) Has been cancelled
Some checks failed
Build and Push Docker Image / Build image (push) Has been cancelled
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user