mirror of https://gitlab.com/bashrc2/epicyon
Validation pattern for nickname on login screen
parent
6d6af419fa
commit
f6ee975236
53
utils.py
53
utils.py
|
@ -1567,27 +1567,44 @@ def isValidLanguage(text: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _getReservedWords() -> str:
|
||||||
|
return ('inbox', 'dm', 'outbox', 'following',
|
||||||
|
'public', 'followers', 'category',
|
||||||
|
'channel', 'calendar',
|
||||||
|
'tlreplies', 'tlmedia', 'tlblogs',
|
||||||
|
'tlblogs', 'tlfeatures',
|
||||||
|
'moderation', 'moderationaction',
|
||||||
|
'activity', 'undo', 'pinned',
|
||||||
|
'reply', 'replies', 'question', 'like',
|
||||||
|
'likes', 'users', 'statuses', 'tags',
|
||||||
|
'accounts', 'headers',
|
||||||
|
'channels', 'profile', 'u', 'c',
|
||||||
|
'updates', 'repeat', 'announce',
|
||||||
|
'shares', 'fonts', 'icons', 'avatars',
|
||||||
|
'welcome', 'helpimages',
|
||||||
|
'bookmark', 'bookmarks', 'tlbookmarks',
|
||||||
|
'ignores', 'linksmobile', 'newswiremobile',
|
||||||
|
'minimal', 'search', 'eventdelete',
|
||||||
|
'searchemoji', 'catalog')
|
||||||
|
|
||||||
|
|
||||||
|
def getNicknameValidationPattern() -> str:
|
||||||
|
"""Returns a html text input validation pattern for nickname
|
||||||
|
"""
|
||||||
|
reservedNames = _getReservedWords()
|
||||||
|
pattern = ''
|
||||||
|
for word in reservedNames:
|
||||||
|
if pattern:
|
||||||
|
pattern += '|' + word
|
||||||
|
else:
|
||||||
|
pattern = '[^(' + word
|
||||||
|
return pattern + ')]'
|
||||||
|
|
||||||
|
|
||||||
def _isReservedName(nickname: str) -> bool:
|
def _isReservedName(nickname: str) -> bool:
|
||||||
"""Is the given nickname reserved for some special function?
|
"""Is the given nickname reserved for some special function?
|
||||||
"""
|
"""
|
||||||
reservedNames = ('inbox', 'dm', 'outbox', 'following',
|
reservedNames = _getReservedWords()
|
||||||
'public', 'followers', 'category',
|
|
||||||
'channel', 'calendar',
|
|
||||||
'tlreplies', 'tlmedia', 'tlblogs',
|
|
||||||
'tlblogs', 'tlfeatures',
|
|
||||||
'moderation', 'moderationaction',
|
|
||||||
'activity', 'undo', 'pinned',
|
|
||||||
'reply', 'replies', 'question', 'like',
|
|
||||||
'likes', 'users', 'statuses', 'tags',
|
|
||||||
'accounts', 'headers',
|
|
||||||
'channels', 'profile', 'u', 'c',
|
|
||||||
'updates', 'repeat', 'announce',
|
|
||||||
'shares', 'fonts', 'icons', 'avatars',
|
|
||||||
'welcome', 'helpimages',
|
|
||||||
'bookmark', 'bookmarks', 'tlbookmarks',
|
|
||||||
'ignores', 'linksmobile', 'newswiremobile',
|
|
||||||
'minimal', 'search', 'eventdelete',
|
|
||||||
'searchemoji', 'catalog')
|
|
||||||
if nickname in reservedNames:
|
if nickname in reservedNames:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -12,6 +12,7 @@ import time
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import noOfAccounts
|
from utils import noOfAccounts
|
||||||
|
from utils import getNicknameValidationPattern
|
||||||
from webapp_utils import htmlHeaderWithWebsiteMarkup
|
from webapp_utils import htmlHeaderWithWebsiteMarkup
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from webapp_utils import htmlKeyboardNavigation
|
from webapp_utils import htmlKeyboardNavigation
|
||||||
|
@ -152,6 +153,7 @@ def htmlLogin(cssCache: {}, translate: {},
|
||||||
htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle,
|
htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle,
|
||||||
httpPrefix, domain,
|
httpPrefix, domain,
|
||||||
systemLanguage)
|
systemLanguage)
|
||||||
|
nicknamePattern = getNicknameValidationPattern()
|
||||||
instanceTitle = getConfigParam(baseDir, 'instanceTitle')
|
instanceTitle = getConfigParam(baseDir, 'instanceTitle')
|
||||||
loginForm += \
|
loginForm += \
|
||||||
'<br>\n' + \
|
'<br>\n' + \
|
||||||
|
@ -167,8 +169,8 @@ def htmlLogin(cssCache: {}, translate: {},
|
||||||
' <label for="nickname"><b>' + \
|
' <label for="nickname"><b>' + \
|
||||||
translate['Nickname'] + '</b></label>\n' + \
|
translate['Nickname'] + '</b></label>\n' + \
|
||||||
' <input type="text" ' + autocompleteStr + ' placeholder="' + \
|
' <input type="text" ' + autocompleteStr + ' placeholder="' + \
|
||||||
translate['Enter Nickname'] + \
|
translate['Enter Nickname'] + '" name="username" ' + \
|
||||||
'" name="username" required autofocus>\n' + \
|
'pattern="' + nicknamePattern + '" required autofocus>\n' + \
|
||||||
'\n' + \
|
'\n' + \
|
||||||
' <label for="password"><b>' + \
|
' <label for="password"><b>' + \
|
||||||
translate['Password'] + '</b></label>\n' + \
|
translate['Password'] + '</b></label>\n' + \
|
||||||
|
|
Loading…
Reference in New Issue