From 2bac46cfb4b13a273f4ffda0a6cdd79a95f0b104 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 19 Jan 2020 20:42:03 +0000 Subject: [PATCH] Upgrade actor on login --- daemon.py | 7 ++++++- person.py | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/daemon.py b/daemon.py index 995a2407..2513112b 100644 --- a/daemon.py +++ b/daemon.py @@ -36,6 +36,7 @@ from matrix import getMatrixAddress from matrix import setMatrixAddress from donate import getDonationUrl from donate import setDonationUrl +from person import personUpgradeActor from person import activateAccount from person import deactivateAccount from person import registerAccount @@ -3911,15 +3912,19 @@ class PubServer(BaseHTTPRequestHandler): token=sha256((loginNickname+loginPassword+salt).encode('utf-8')).hexdigest() self.server.tokens[loginNickname]=token + loginHandle=loginNickname+'@'+self.server.domain tokenFilename= \ self.server.baseDir+'/accounts/'+ \ - loginNickname+'@'+self.server.domain+'/.token' + loginHandle+'/.token' try: with open(tokenFilename, 'w') as fp: fp.write(token) except Exception as e: print('WARN: Unable to save token for '+loginNickname+' '+str(e)) + personUpgradeActor(None,loginHandle, \ + self.server.baseDir+'/accounts/'+loginHandle+'.json') + self.server.tokensLookup[self.server.tokens[loginNickname]]=loginNickname self.send_header('Set-Cookie', \ 'epicyon='+self.server.tokens[loginNickname]+'; SameSite=Strict') diff --git a/person.py b/person.py index 276d61c2..34c90bf7 100644 --- a/person.py +++ b/person.py @@ -375,7 +375,9 @@ def createCapabilitiesInbox(baseDir: str,nickname: str,domain: str,port: int, \ def personUpgradeActor(personJson: {},handle: str,filename: str) -> None: """Alter the actor to add any new properties - """ + """ + if not personJson: + personJson=loadJson(filename) if not personJson.get('nomadicLocations'): personJson['nomadicLocations']=[{ 'id': personJson['id'],