Tidying of login screen call

merge-requests/30/head
Bob Mottram 2024-04-18 15:22:43 +01:00
parent 2421599986
commit d4692f9566
2 changed files with 42 additions and 14 deletions

View File

@ -203,6 +203,7 @@ from daemon_get_vcard import show_vcard
from daemon_get_blog import show_blog_page
from daemon_get_links import edit_links2
from daemon_get_login import redirect_to_login_screen
from daemon_get_login import show_login_screen
# Blogs can be longer, so don't show many per page
MAX_POSTS_IN_BLOGS_FEED = 4
@ -2688,24 +2689,18 @@ def daemon_http_get(self) -> None:
self.server.debug)
# show the login screen
if (self.path.startswith('/login') or
(self.path == '/' and
not authorized and
not self.server.news_instance)):
# request basic auth
msg = html_login(self.server.translate,
if show_login_screen(self.path, authorized,
self.server.news_instance,
self.server.translate,
self.server.base_dir,
self.server.http_prefix,
self.server.domain_full,
self.server.system_language,
True, ua_str,
self.server.theme_name).encode('utf-8')
msglen = len(msg)
login_headers(self, 'text/html', msglen, calling_domain)
write2(self, msg)
fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'login shown',
self.server.debug)
ua_str, self.server.theme_name,
calling_domain,
getreq_start_time,
self.server.fitness, self.server.debug,
self):
self.server.getreq_busy = False
return

View File

@ -10,8 +10,11 @@ __module_group__ = "Core GET"
from utils import get_instance_url
from utils import string_ends_with
from utils import string_contains
from httpcodes import write2
from httpheaders import login_headers
from httpheaders import redirect_headers
from fitnessFunctions import fitness_performance
from webapp_login import html_login
def redirect_to_login_screen(self, calling_domain: str, path: str,
@ -61,3 +64,33 @@ def redirect_to_login_screen(self, calling_domain: str, path: str,
debug)
return True
return False
def show_login_screen(path: str, authorized: bool,
news_instance: bool,
translate: {},
base_dir: str,
http_prefix: str,
domain_full: str,
system_language: str,
ua_str: str, theme_name: str,
calling_domain: str,
getreq_start_time,
fitness: {}, debug: bool,
self) -> bool:
""" Shows the login screen
"""
if path.startswith('/login') or \
(path == '/' and not authorized and not news_instance):
# request basic auth
msg = html_login(translate, base_dir,
http_prefix, domain_full,
system_language, True, ua_str,
theme_name).encode('utf-8')
msglen = len(msg)
login_headers(self, 'text/html', msglen, calling_domain)
write2(self, msg)
fitness_performance(getreq_start_time, fitness,
'_GET', 'login shown', debug)
return True
return False