forked from indymedia/epicyon
Upgrade actor on login
parent
d30d519d22
commit
2bac46cfb4
|
@ -36,6 +36,7 @@ from matrix import getMatrixAddress
|
||||||
from matrix import setMatrixAddress
|
from matrix import setMatrixAddress
|
||||||
from donate import getDonationUrl
|
from donate import getDonationUrl
|
||||||
from donate import setDonationUrl
|
from donate import setDonationUrl
|
||||||
|
from person import personUpgradeActor
|
||||||
from person import activateAccount
|
from person import activateAccount
|
||||||
from person import deactivateAccount
|
from person import deactivateAccount
|
||||||
from person import registerAccount
|
from person import registerAccount
|
||||||
|
@ -3911,15 +3912,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
token=sha256((loginNickname+loginPassword+salt).encode('utf-8')).hexdigest()
|
token=sha256((loginNickname+loginPassword+salt).encode('utf-8')).hexdigest()
|
||||||
self.server.tokens[loginNickname]=token
|
self.server.tokens[loginNickname]=token
|
||||||
|
loginHandle=loginNickname+'@'+self.server.domain
|
||||||
tokenFilename= \
|
tokenFilename= \
|
||||||
self.server.baseDir+'/accounts/'+ \
|
self.server.baseDir+'/accounts/'+ \
|
||||||
loginNickname+'@'+self.server.domain+'/.token'
|
loginHandle+'/.token'
|
||||||
try:
|
try:
|
||||||
with open(tokenFilename, 'w') as fp:
|
with open(tokenFilename, 'w') as fp:
|
||||||
fp.write(token)
|
fp.write(token)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: Unable to save token for '+loginNickname+' '+str(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.server.tokensLookup[self.server.tokens[loginNickname]]=loginNickname
|
||||||
self.send_header('Set-Cookie', \
|
self.send_header('Set-Cookie', \
|
||||||
'epicyon='+self.server.tokens[loginNickname]+'; SameSite=Strict')
|
'epicyon='+self.server.tokens[loginNickname]+'; SameSite=Strict')
|
||||||
|
|
|
@ -375,7 +375,9 @@ def createCapabilitiesInbox(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
|
|
||||||
def personUpgradeActor(personJson: {},handle: str,filename: str) -> None:
|
def personUpgradeActor(personJson: {},handle: str,filename: str) -> None:
|
||||||
"""Alter the actor to add any new properties
|
"""Alter the actor to add any new properties
|
||||||
"""
|
"""
|
||||||
|
if not personJson:
|
||||||
|
personJson=loadJson(filename)
|
||||||
if not personJson.get('nomadicLocations'):
|
if not personJson.get('nomadicLocations'):
|
||||||
personJson['nomadicLocations']=[{
|
personJson['nomadicLocations']=[{
|
||||||
'id': personJson['id'],
|
'id': personJson['id'],
|
||||||
|
|
Loading…
Reference in New Issue