Fix always creating new account

This commit is contained in:
Li 2023-01-29 17:50:18 -08:00
parent 301067be0d
commit fe17f5e854
2 changed files with 13 additions and 6 deletions

1
.gitignore vendored
View File

@ -160,3 +160,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
settings.json

View File

@ -68,19 +68,24 @@ def genPlayFabSignature(requestBody, timestamp):
sha256 = hashlib.sha256() sha256 = hashlib.sha256()
sha256.update(requestBody.encode("UTF-8") + b"." + timestamp.encode("UTF-8") + b"." + configGet("PLAYER_SECRET").encode("UTF-8")) sha256.update(requestBody.encode("UTF-8") + b"." + timestamp.encode("UTF-8") + b"." + configGet("PLAYER_SECRET").encode("UTF-8"))
return base64.b64encode(sha256.digest()) 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): def configGet(key):
global PLAYFAB_SETTINGS global PLAYFAB_SETTINGS
configLoad()
if key in PLAYFAB_SETTINGS: if key in PLAYFAB_SETTINGS:
return PLAYFAB_SETTINGS[key] return PLAYFAB_SETTINGS[key]
return None return None
def configSet(key, newValue): def configSet(key, newValue):
global PLAYFAB_SETTINGS global PLAYFAB_SETTINGS
if os.path.exists(SETTING_FILE): configLoad()
PLAYFAB_SETTINGS = json.loads(open(SETTING_FILE, "r").read())
PLAYFAB_SETTINGS[key] = newValue PLAYFAB_SETTINGS[key] = newValue
open(SETTING_FILE, "w").write(json.dumps(PLAYFAB_SETTINGS)) open(SETTING_FILE, "w").write(json.dumps(PLAYFAB_SETTINGS))
return newValue return newValue
@ -167,4 +172,5 @@ def Search(query, sfilter, orderBy, select, top, skip):
"select": select, "select": select,
"top": top, "top": top,
"skip": skip "skip": skip
}) })