Skip to content

Commit

Permalink
set jwt if plugin_jwt is available
Browse files Browse the repository at this point in the history
  • Loading branch information
xavluiz committed Jan 4, 2021
1 parent e9c01bd commit 6311c74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion lib/CommonUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,17 @@ def getPluginUuid():

def getAuthCallbackState():
jsonObj = getDeviceAsJson()
return jsonObj.get("auth_callback_state", None)
auth_callback_state = jsonObj.get("auth_callback_state", None)
if (auth_callback_state is None):
auth_callback_state = str(uuid.uuid4())
jsonObj["auth_callback_state"] = auth_callback_state
content = json.dumps(jsonObj)

deviceFile = getDeviceFile()
with open(deviceFile, 'w') as f:
f.write(content)

return auth_callback_state

def setAuthCallbackState(value):
jsonObj = getDeviceAsJson()
Expand Down
8 changes: 5 additions & 3 deletions lib/SoftwareUserStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ def isLoggedOn():

if (user is not None):
registered = user.get("registered", 0)
setItem("jwt", user.get("plugin_jwt"))
user_jwt = user.get("plugin_jwt", None)

if (user_jwt is not None):
setItem("jwt", user.get("plugin_jwt"))

if (registered == 1):
setItem("name", user.get("email"))
else:
setItem("name", None)

if (authType is None):
setItem("authType", "software")
Expand Down

0 comments on commit 6311c74

Please sign in to comment.