From 93008d97b10848b3fd560a7959b19e7eeba3146f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 25 Oct 2019 18:41:59 +0100 Subject: [PATCH] Remove token and salt on account suspend --- daemon.py | 2 +- person.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/daemon.py b/daemon.py index b1916a61..e5531eed 100644 --- a/daemon.py +++ b/daemon.py @@ -3154,7 +3154,7 @@ class PubServer(BaseHTTPRequestHandler): if '@' in nickname: nickname=nickname.split('@')[0] if moderationButton=='suspend': - suspendAccount(self.server.baseDir,nickname) + suspendAccount(self.server.baseDir,nickname,self.server.domain) if moderationButton=='unsuspend': unsuspendAccount(self.server.baseDir,nickname) if moderationButton=='block': diff --git a/person.py b/person.py index 0f413cfd..5de1d0b2 100644 --- a/person.py +++ b/person.py @@ -566,7 +566,7 @@ def unsuspendAccount(baseDir: str,nickname: str) -> None: suspendedFile.write(suspended) suspendedFile.close() -def suspendAccount(baseDir: str,nickname: str) -> None: +def suspendAccount(baseDir: str,nickname: str,domain: str) -> None: """Suspends the given account """ # Don't suspend the admin @@ -583,6 +583,13 @@ def suspendAccount(baseDir: str,nickname: str) -> None: if moderator.strip('\n')==nickname: 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' if os.path.isfile(suspendedFilename): with open(suspendedFilename, "r") as f: