AY 4 rokov pred
rodič
commit
ac6db8e3b2
3 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  1. BIN
      __debug_bin
  2. 4 0
      mod/config/whitelist.go
  3. 1 1
      server/whitelist.json

BIN
__debug_bin


+ 4 - 0
mod/config/whitelist.go

@@ -27,12 +27,14 @@ func (mch *Handler) ReadAllWhitelists() Whitelist {
 
 //WriteWhitelist is exported function
 func (mch *Handler) WriteWhitelist(UUID string, Name string) bool {
+	mch.ReadAllWhitelists()
 	newItem := Whitelist{}
 	newItem = append(newItem, struct {
 		UUID string `json:"uuid"`
 		Name string `json:"name"`
 	}{UUID, Name})
 	mch.whitelists = append(mch.whitelists, newItem...)
+	mch.SaveAllWhitelists()
 	return true
 }
 
@@ -58,6 +60,7 @@ func (mch *Handler) ReadWhitelist(search string, field string) Whitelist {
 
 //RemoveWhitelist is exported function
 func (mch *Handler) RemoveWhitelist(search string, field string) bool {
+	mch.ReadAllWhitelists()
 	for i, item := range mch.whitelists {
 		fieldValue := ""
 		switch strings.ToLower(field) {
@@ -77,6 +80,7 @@ func (mch *Handler) RemoveWhitelist(search string, field string) bool {
 			}
 		}
 	}
+	mch.SaveAllWhitelists()
 	return true
 }
 

+ 1 - 1
server/whitelist.json

@@ -1 +1 @@
-[{"uuid":"1234","name":"TC"}]
+[{"uuid":"3d1c0ed1-d4d0-42ae-ac5e-a7557d5a6c4f","name":"Alanyeung"}]