Upgrade actor on login

main
Bob Mottram 2020-01-19 20:42:03 +00:00
parent d30d519d22
commit 2bac46cfb4
2 changed files with 9 additions and 2 deletions

View File

@ -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')

View File

@ -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'],