mirror of https://gitlab.com/bashrc2/epicyon
Screen for suspended accounts
parent
625e5eb011
commit
2fdd644c87
|
@ -26,6 +26,7 @@ from person import registerAccount
|
|||
from person import personLookup
|
||||
from person import personBoxJson
|
||||
from person import createSharedInbox
|
||||
from person import isSuspended
|
||||
from posts import outboxMessageCreateWrap
|
||||
from posts import savePostToBox
|
||||
from posts import sendToFollowers
|
||||
|
@ -73,6 +74,7 @@ from webinterface import htmlOutbox
|
|||
from webinterface import htmlModeration
|
||||
from webinterface import htmlPostReplies
|
||||
from webinterface import htmlLogin
|
||||
from webinterface import htmlSuspended
|
||||
from webinterface import htmlGetLoginCredentials
|
||||
from webinterface import htmlNewPost
|
||||
from webinterface import htmlFollowConfirm
|
||||
|
@ -1853,6 +1855,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.POSTbusy=False
|
||||
return
|
||||
else:
|
||||
if isSuspended(self.server.baseDir,loginNickname):
|
||||
self._login_headers('text/html')
|
||||
self.wfile.write(htmlSuspended(self.server.baseDir).encode('utf-8'))
|
||||
self.server.POSTbusy=False
|
||||
return
|
||||
# login success - redirect with authorization
|
||||
print('Login success: '+loginNickname)
|
||||
self.send_response(303)
|
||||
|
|
69
person.py
69
person.py
|
@ -463,3 +463,72 @@ def setBio(baseDir: str,nickname: str, domain: str, bio: str) -> bool:
|
|||
with open(filename, 'w') as fp:
|
||||
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
|
||||
return True
|
||||
|
||||
def isSuspended(baseDir: str,nickname: str) -> bool:
|
||||
"""Returns true if the given nickname is suspended
|
||||
"""
|
||||
adminNickname=getConfigParam(baseDir,'admin')
|
||||
if nickname==adminNickname:
|
||||
return False
|
||||
|
||||
suspendedFilename=baseDir+'/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
with open(suspendedFilename, "r") as f:
|
||||
lines = f.readlines()
|
||||
suspendedFile=open(suspendedFilename,"w+")
|
||||
for suspended in lines:
|
||||
if suspended.strip('\n')==nickname:
|
||||
return True
|
||||
return False
|
||||
|
||||
def unsuspendAccount(baseDir: str,nickname: str) -> None:
|
||||
"""Removes an account suspention
|
||||
"""
|
||||
suspendedFilename=baseDir+'/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
with open(suspendedFilename, "r") as f:
|
||||
lines = f.readlines()
|
||||
suspendedFile=open(suspendedFilename,"w+")
|
||||
for suspended in lines:
|
||||
if suspended.strip('\n')!=nickname:
|
||||
suspendedFile.write(suspended)
|
||||
suspendedFile.close()
|
||||
|
||||
def suspendAccount(baseDir: str,nickname: str,salts: {}) -> None:
|
||||
"""Suspends the given account
|
||||
This also changes the salt used by the authentication token
|
||||
so that the person can't continue to use the system without
|
||||
going through the login screen
|
||||
"""
|
||||
# Don't suspend the admin
|
||||
adminNickname=getConfigParam(baseDir,'admin')
|
||||
if nickname==adminNickname:
|
||||
return
|
||||
|
||||
# Don't suspend moderators
|
||||
moderatorsFile=baseDir+'/accounts/moderators.txt'
|
||||
if os.path.isfile(moderatorsFile):
|
||||
with open(moderatorsFile, "r") as f:
|
||||
lines = f.readlines()
|
||||
for moderator in lines:
|
||||
if moderator.strip('\n')==nickname:
|
||||
return
|
||||
|
||||
suspendedFilename=baseDir+'/accounts/suspended.txt'
|
||||
if os.path.isfile(suspendedFilename):
|
||||
with open(suspendedFilename, "r") as f:
|
||||
lines = f.readlines()
|
||||
for suspended in lines:
|
||||
if suspended.strip('\n')==nickname:
|
||||
return
|
||||
suspendedFile=open(suspendedFilename,'a+')
|
||||
if suspendedFile:
|
||||
suspendedFile.write(nickname+'\n')
|
||||
suspendedFile.close()
|
||||
salts[nickname]=createPassword(32)
|
||||
else:
|
||||
suspendedFile=open(suspendedFilename,'w+')
|
||||
if suspendedFile:
|
||||
suspendedFile.write(nickname+'\n')
|
||||
suspendedFile.close()
|
||||
salts[nickname]=createPassword(32)
|
||||
|
|
|
@ -319,6 +319,8 @@ def htmlLogin(baseDir: str) -> str:
|
|||
return loginForm
|
||||
|
||||
def htmlTermsOfService(baseDir: str,httpPrefix: str,domainFull: str) -> str:
|
||||
"""Show the terms of service screen
|
||||
"""
|
||||
adminNickname = getConfigParam(baseDir,'admin')
|
||||
if not os.path.isfile(baseDir+'/accounts/tos.txt'):
|
||||
copyfile(baseDir+'/default_tos.txt',baseDir+'/accounts/tos.txt')
|
||||
|
@ -343,6 +345,20 @@ def htmlTermsOfService(baseDir: str,httpPrefix: str,domainFull: str) -> str:
|
|||
TOSForm+=htmlFooter()
|
||||
return TOSForm
|
||||
|
||||
def htmlSuspended(baseDir: str) -> str:
|
||||
"""Show the screen for suspended accounts
|
||||
"""
|
||||
suspendedForm=''
|
||||
with open(baseDir+'/epicyon-suspended.css', 'r') as cssFile:
|
||||
suspendedCSS=cssFile.read()
|
||||
suspendedForm=htmlHeader(suspendedCSS)
|
||||
suspendedForm+='<div><center>'
|
||||
suspendedForm+=' <p class="screentitle">Account Suspended</p>'
|
||||
suspendedForm+=' <p>See <a href="/terms">Terms of Service</a></p>'
|
||||
suspendedForm+='</center></div>'
|
||||
suspendedForm+=htmlFooter()
|
||||
return suspendedForm
|
||||
|
||||
def htmlNewPost(baseDir: str,path: str,inReplyTo: str,mentions: []) -> str:
|
||||
reportUrl=None
|
||||
if '/newreport?=' in path:
|
||||
|
|
Loading…
Reference in New Issue