mirror of https://gitlab.com/bashrc2/epicyon
Functions for activating and deactivating accounts
parent
1c42e9a640
commit
4d88fa3ead
|
@ -23,6 +23,7 @@ from session import createSession
|
|||
from webfinger import webfingerMeta
|
||||
from webfinger import webfingerLookup
|
||||
from webfinger import webfingerHandle
|
||||
from person import activateAccount
|
||||
from person import registerAccount
|
||||
from person import personLookup
|
||||
from person import personBoxJson
|
||||
|
@ -3024,10 +3025,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._login_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self.server.POSTbusy=False
|
||||
return
|
||||
return
|
||||
# login success - redirect with authorization
|
||||
print('Login success: '+loginNickname)
|
||||
self.send_response(303)
|
||||
# re-activate account if needed
|
||||
activateAccount(baseDir,loginNickname,self.server.domain)
|
||||
# This produces a deterministic token based on nick+password+salt
|
||||
saltFilename= \
|
||||
self.server.baseDir+'/accounts/'+ \
|
||||
|
|
21
person.py
21
person.py
|
@ -696,3 +696,24 @@ def removeAccount(baseDir: str,nickname: str,domain: str,port: int) -> bool:
|
|||
if os.path.isdir(baseDir+'/sharefiles/'+nickname):
|
||||
shutil.rmtree(baseDir+'/sharefiles/'+nickname)
|
||||
return True
|
||||
|
||||
def deactivateAccount(baseDir: str,nickname: str,domain: str) -> None:
|
||||
"""Makes an account temporarily unavailable
|
||||
"""
|
||||
accountDir=baseDir+'/accounts/'+nickname+'@'+domain
|
||||
if not os.path.isdir(accountDir):
|
||||
return
|
||||
deactivatedDir=baseDir+'/deactivated'
|
||||
if not os.path.isdir(deactivatedDir):
|
||||
os.mkdir(deactivatedDir)
|
||||
shutil.move(accountDir,deactivatedDir+'/'+nickname+'@'+domain)
|
||||
|
||||
def activateAccount(baseDir: str,nickname: str,domain: str) -> None:
|
||||
"""Makes a deactivated account available
|
||||
"""
|
||||
deactivatedDir=baseDir+'/deactivated'
|
||||
deactivatedAccountDir=deactivatedDir+'/'+nickname+'@'+domain
|
||||
if not os.path.isdir(deactivatedAccountDir):
|
||||
return
|
||||
accountDir=baseDir+'/accounts/'+nickname+'@'+domain
|
||||
shutil.move(deactivatedAccountDir,accountDir)
|
||||
|
|
Loading…
Reference in New Issue