Remove token and salt on account suspend

main2
Bob Mottram 2019-10-25 18:41:59 +01:00
parent 5f5bb5290d
commit 93008d97b1
2 changed files with 9 additions and 2 deletions

View File

@ -3154,7 +3154,7 @@ class PubServer(BaseHTTPRequestHandler):
if '@' in nickname: if '@' in nickname:
nickname=nickname.split('@')[0] nickname=nickname.split('@')[0]
if moderationButton=='suspend': if moderationButton=='suspend':
suspendAccount(self.server.baseDir,nickname) suspendAccount(self.server.baseDir,nickname,self.server.domain)
if moderationButton=='unsuspend': if moderationButton=='unsuspend':
unsuspendAccount(self.server.baseDir,nickname) unsuspendAccount(self.server.baseDir,nickname)
if moderationButton=='block': if moderationButton=='block':

View File

@ -566,7 +566,7 @@ def unsuspendAccount(baseDir: str,nickname: str) -> None:
suspendedFile.write(suspended) suspendedFile.write(suspended)
suspendedFile.close() suspendedFile.close()
def suspendAccount(baseDir: str,nickname: str) -> None: def suspendAccount(baseDir: str,nickname: str,domain: str) -> None:
"""Suspends the given account """Suspends the given account
""" """
# Don't suspend the admin # Don't suspend the admin
@ -583,6 +583,13 @@ def suspendAccount(baseDir: str,nickname: str) -> None:
if moderator.strip('\n')==nickname: if moderator.strip('\n')==nickname:
return return
saltFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/.salt'
if os.path.isfile(saltFilename):
os.remove(saltFilename)
tokenFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/.token'
if os.path.isfile(tokenFilename):
os.remove(tokenFilename)
suspendedFilename=baseDir+'/accounts/suspended.txt' suspendedFilename=baseDir+'/accounts/suspended.txt'
if os.path.isfile(suspendedFilename): if os.path.isfile(suspendedFilename):
with open(suspendedFilename, "r") as f: with open(suspendedFilename, "r") as f: