More checks that admin user is defined

main
Bob Mottram 2020-10-10 17:10:32 +01:00
parent fb1d561bae
commit 22f31f0356
3 changed files with 16 additions and 2 deletions

View File

@ -789,6 +789,8 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
"""
# Don't suspend the admin
adminNickname = getConfigParam(baseDir, 'admin')
if not adminNickname:
return
if nickname == adminNickname:
return
@ -843,6 +845,8 @@ def canRemovePost(baseDir: str, nickname: str,
# is the post by the admin?
adminNickname = getConfigParam(baseDir, 'admin')
if not adminNickname:
return False
if domainFull + '/users/' + adminNickname + '/' in postId:
return False
@ -899,6 +903,8 @@ def removeAccount(baseDir: str, nickname: str,
"""
# Don't remove the admin
adminNickname = getConfigParam(baseDir, 'admin')
if not adminNickname:
return False
if nickname == adminNickname:
return False

View File

@ -74,14 +74,20 @@ def isModerator(baseDir: str, nickname: str) -> bool:
moderatorsFile = baseDir + '/accounts/moderators.txt'
if not os.path.isfile(moderatorsFile):
if getConfigParam(baseDir, 'admin') == nickname:
adminName = getConfigParam(baseDir, 'admin')
if not adminName:
return False
if adminName == nickname:
return True
return False
with open(moderatorsFile, "r") as f:
lines = f.readlines()
if len(lines) == 0:
if getConfigParam(baseDir, 'admin') == nickname:
adminName = getConfigParam(baseDir, 'admin')
if not adminName:
return False
if adminName == nickname:
return True
for moderator in lines:
moderator = moderator.strip('\n').strip('\r')

View File

@ -58,6 +58,8 @@ def isSuspended(baseDir: str, nickname: str) -> bool:
"""Returns true if the given nickname is suspended
"""
adminNickname = getConfigParam(baseDir, 'admin')
if not adminNickname:
return False
if nickname == adminNickname:
return False