Bladeren bron

auth work

reid 2 jaren geleden
bovenliggende
commit
a0b5289bff
2 gewijzigde bestanden met toevoegingen van 11 en 13 verwijderingen
  1. 9 11
      auth/auth.go
  2. 2 2
      system/system.go

+ 9 - 11
auth/auth.go

@@ -190,9 +190,8 @@ func AddSession(tokenID string, hash string, created string, authorized bool) er
 	if authorized {
 		update := map[string]interface{}{
 			"Sessions": map[string]interface{}{
-				"Authorized": map[string]string{
-					"Hash":    session.Hash,
-					"Created": session.Created,
+				"Authorized": map[string]structs.SessionInfo{
+					tokenID: session,
 				},
 			},
 		}
@@ -202,15 +201,14 @@ func AddSession(tokenID string, hash string, created string, authorized bool) er
 		if err := config.RemoveSession(tokenID, false); err != nil {
 			return fmt.Errorf("Error removing session: %v", err)
 		}
-	} else {
-		update := map[string]interface{}{
-			"Sessions": map[string]interface{}{
-				"Unauthorized": map[string]string{
-					"Hash":    session.Hash,
-					"Created": session.Created,
+		} else {
+			update := map[string]interface{}{
+				"Sessions": map[string]interface{}{
+					"Unauthorized": map[string]structs.SessionInfo{
+						tokenID: session,
+					},
 				},
-			},
-		}
+			}
 		if err := config.UpdateConf(update); err != nil {
 			return fmt.Errorf("Error adding session: %v", err)
 		}

+ 2 - 2
system/system.go

@@ -14,10 +14,10 @@ import (
 	"time"
 )
 
-// get memory used/avail in bytes
+// get memory total/used in bytes
 func GetMemory() (uint64, uint64) {
 	v, _ := mem.VirtualMemory()
-	return v.Used, v.Total
+	return v.Total, v.Used
 }
 
 // get cpu usage as %