mirror of https://gitlab.com/bashrc2/epicyon
Register button
parent
ebcdbf74b4
commit
13dc4e889b
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
all:
|
||||
debug:
|
||||
clean:
|
||||
rm -f *.py~ Makefile~ README.md~
|
||||
rm -f *.md~ *.py~ *.json~ *.css~ Makefile~
|
||||
rm -rf __pycache__
|
||||
|
|
|
@ -1193,6 +1193,8 @@ if args.testdata:
|
|||
password='boringpassword'
|
||||
print('Generating some test data for user: '+nickname)
|
||||
|
||||
setConfigParam(baseDir,'registrationsRemaining',str(maxRegistrations))
|
||||
|
||||
createPerson(baseDir,'maxboardroom',domain,port,httpPrefix,True,password)
|
||||
createPerson(baseDir,'ultrapancake',domain,port,httpPrefix,True,password)
|
||||
createPerson(baseDir,'drokk',domain,port,httpPrefix,True,password)
|
||||
|
|
12
person.py
12
person.py
|
@ -23,6 +23,7 @@ from auth import storeBasicCredentials
|
|||
from roles import setRole
|
||||
from media import removeMetaData
|
||||
from utils import validNickname
|
||||
from utils import noOfAccounts
|
||||
from config import setConfigParam
|
||||
from config import getConfigParam
|
||||
|
||||
|
@ -217,17 +218,6 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
|||
|
||||
return privateKeyPem,publicKeyPem,newPerson,webfingerEndpoint
|
||||
|
||||
def noOfAccounts(baseDir: str) -> bool:
|
||||
"""Returns the number of accounts on the system
|
||||
"""
|
||||
accountCtr=0
|
||||
for subdir, dirs, files in os.walk(baseDir+'/accounts'):
|
||||
for account in dirs:
|
||||
if '@' in account:
|
||||
if not account.startswith('inbox'):
|
||||
accountCtr+=1
|
||||
return accountCtr
|
||||
|
||||
def createPerson(baseDir: str,nickname: str,domain: str,port: int, \
|
||||
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
|
|
11
utils.py
11
utils.py
|
@ -200,3 +200,14 @@ def validNickname(nickname: str) -> bool:
|
|||
if nickname in reservedNames:
|
||||
return False
|
||||
return True
|
||||
|
||||
def noOfAccounts(baseDir: str) -> bool:
|
||||
"""Returns the number of accounts on the system
|
||||
"""
|
||||
accountCtr=0
|
||||
for subdir, dirs, files in os.walk(baseDir+'/accounts'):
|
||||
for account in dirs:
|
||||
if '@' in account:
|
||||
if not account.startswith('inbox'):
|
||||
accountCtr+=1
|
||||
return accountCtr
|
||||
|
|
|
@ -17,6 +17,7 @@ from person import personBoxJson
|
|||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
from utils import locatePost
|
||||
from utils import noOfAccounts
|
||||
from follow import isFollowingActor
|
||||
from webfinger import webfingerHandle
|
||||
from posts import getPersonBox
|
||||
|
@ -29,6 +30,7 @@ from like import likedByPerson
|
|||
from announce import announcedByPerson
|
||||
from blocking import isBlocked
|
||||
from content import getMentionsFromHtml
|
||||
from config import getConfigParam
|
||||
|
||||
def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str:
|
||||
"""Shows the edit profile screen
|
||||
|
@ -150,13 +152,18 @@ def htmlGetLoginCredentials(loginParams: str,lastLoginTime: int) -> (str,str):
|
|||
return nickname,password
|
||||
|
||||
def htmlLogin(baseDir: str) -> str:
|
||||
accounts=noOfAccounts(baseDir)
|
||||
|
||||
if not os.path.isfile(baseDir+'/accounts/login.png'):
|
||||
copyfile(baseDir+'/img/login.png',baseDir+'/accounts/login.png')
|
||||
if os.path.isfile(baseDir+'/img/login-background.png'):
|
||||
if not os.path.isfile(baseDir+'/accounts/login-background.png'):
|
||||
copyfile(baseDir+'/img/login-background.png',baseDir+'/accounts/login-background.png')
|
||||
|
||||
loginText='<p class="login-text">Welcome. Please enter your login details below.</p>'
|
||||
if accounts>0:
|
||||
loginText='<p class="login-text">Welcome. Please enter your login details below.</p>'
|
||||
else:
|
||||
loginText='<p class="login-text">Please enter some credentials</p><p>You will become the admin of this site.</p>'
|
||||
if os.path.isfile(baseDir+'/accounts/login.txt'):
|
||||
with open(baseDir+'/accounts/login.txt', 'r') as file:
|
||||
loginText = '<p class="login-text">'+file.read()+'</p>'
|
||||
|
@ -164,6 +171,16 @@ def htmlLogin(baseDir: str) -> str:
|
|||
with open(baseDir+'/epicyon-login.css', 'r') as cssFile:
|
||||
loginCSS = cssFile.read()
|
||||
|
||||
# show the register button
|
||||
registerButtonStr=''
|
||||
if getConfigParam(baseDir,'registration')=='open':
|
||||
if int(getConfigParam(baseDir,'registrationsRemaining'))>0:
|
||||
registerButtonStr='<button type="submit" name="register">Register</button>'
|
||||
|
||||
loginButtonStr=''
|
||||
if accounts>0:
|
||||
loginButtonStr='<button type="submit" name="submit">Login</button>'
|
||||
|
||||
loginForm=htmlHeader(loginCSS)
|
||||
loginForm+= \
|
||||
'<form method="POST" action="/login">' \
|
||||
|
@ -177,9 +194,8 @@ def htmlLogin(baseDir: str) -> str:
|
|||
' <input type="text" placeholder="Enter Nickname" name="username" required>' \
|
||||
'' \
|
||||
' <label for="password"><b>Password</b></label>' \
|
||||
' <input type="password" placeholder="Enter Password" name="password" required>' \
|
||||
'' \
|
||||
' <button type="submit" name="submit">Login</button>' \
|
||||
' <input type="password" placeholder="Enter Password" name="password" required>'+ \
|
||||
registerButtonStr+loginButtonStr+ \
|
||||
' </div>' \
|
||||
'</form>'
|
||||
loginForm+=htmlFooter()
|
||||
|
|
Loading…
Reference in New Issue