mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-01 07:02:48 +08:00
fixing runtime panic on user delete
This commit is contained in:
@@ -37,7 +37,7 @@ func CreateServerToken(netID string) (string, error) {
|
||||
accesskey.Name = GenKeyName()
|
||||
accesskey.Value = GenKey()
|
||||
accesskey.Uses = 1
|
||||
gconf, errG := GetGlobalConfig()
|
||||
_, gconf, errG := GetGlobalConfig()
|
||||
if errG != nil {
|
||||
return "", errG
|
||||
}
|
||||
@@ -504,7 +504,9 @@ func UniqueAddress(networkName string) (string, error){
|
||||
}
|
||||
|
||||
//pretty simple get
|
||||
func GetGlobalConfig() ( models.GlobalConfig, error) {
|
||||
func GetGlobalConfig() (bool, models.GlobalConfig, error) {
|
||||
|
||||
create := false
|
||||
|
||||
filter := bson.M{}
|
||||
|
||||
@@ -518,12 +520,16 @@ func GetGlobalConfig() ( models.GlobalConfig, error) {
|
||||
|
||||
defer cancel()
|
||||
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
fmt.Println("Global config does not exist. Need to create.")
|
||||
create = true
|
||||
return create, globalconf, err
|
||||
} else if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Println("Could not get global config")
|
||||
return globalconf, err
|
||||
return create, globalconf, err
|
||||
}
|
||||
return globalconf, err
|
||||
return create, globalconf, err
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user