From fe17f5e8544d57612e0adb59d5ad65e733002edf Mon Sep 17 00:00:00 2001
From: Li
Date: Sun, 29 Jan 2023 17:50:18 -0800
Subject: [PATCH] Fix always creating new account
---
.gitignore | 1 +
PlayFab.py | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5d381cc..cdbbf71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -160,3 +160,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
+settings.json
\ No newline at end of file
diff --git a/PlayFab.py b/PlayFab.py
index 2913cdb..35e23b2 100644
--- a/PlayFab.py
+++ b/PlayFab.py
@@ -68,19 +68,24 @@ def genPlayFabSignature(requestBody, timestamp):
sha256 = hashlib.sha256()
sha256.update(requestBody.encode("UTF-8") + b"." + timestamp.encode("UTF-8") + b"." + configGet("PLAYER_SECRET").encode("UTF-8"))
return base64.b64encode(sha256.digest())
-
+
+def configLoad():
+ global PLAYFAB_SETTINGS
+ global SETTING_FILE
+ if os.path.exists(SETTING_FILE):
+ PLAYFAB_SETTINGS = json.loads(open(SETTING_FILE, "r").read())
+
def configGet(key):
global PLAYFAB_SETTINGS
+ configLoad()
if key in PLAYFAB_SETTINGS:
return PLAYFAB_SETTINGS[key]
return None
def configSet(key, newValue):
- global PLAYFAB_SETTINGS
- if os.path.exists(SETTING_FILE):
- PLAYFAB_SETTINGS = json.loads(open(SETTING_FILE, "r").read())
-
+ global PLAYFAB_SETTINGS
+ configLoad()
PLAYFAB_SETTINGS[key] = newValue
open(SETTING_FILE, "w").write(json.dumps(PLAYFAB_SETTINGS))
return newValue
@@ -167,4 +172,5 @@ def Search(query, sfilter, orderBy, select, top, skip):
"select": select,
"top": top,
"skip": skip
- })
\ No newline at end of file
+ })
+