Let config suppress username field for login screen

This commit is contained in:
Lance Edgar 2023-10-01 19:51:28 -05:00
parent 9268d939eb
commit 069289775e

View file

@ -35,12 +35,18 @@ class LoginView(WuttaView):
Main POS view for WuttaPOS Main POS view for WuttaPOS
""" """
def __init__(self, *args, **kwargs): def __init__(self, config, *args, **kwargs):
# TODO: maybe support setting this to False? for now that's not 100% supported # may or may not show the username field
self.show_username = kwargs.pop('show_username', True) # nb. must set this before normal __init__
if 'show_username' in kwargs:
self.show_username = kwargs.pop('show_username')
else:
self.show_username = config.getbool('wuttapos', 'login.show_username',
default=True)
super().__init__(*args, **kwargs) # build controls
super().__init__(config, *args, **kwargs)
# track which login input has focus # track which login input has focus
self.focused = None self.focused = None
@ -176,7 +182,9 @@ class LoginView(WuttaView):
session = self.app.make_session() session = self.app.make_session()
auth = self.app.get_auth_handler() auth = self.app.get_auth_handler()
user = auth.authenticate_user(session, self.username.value, self.password.value) user = auth.authenticate_user(session,
self.username.value if self.show_username else None,
self.password.value)
user_display = str(user) if user else None user_display = str(user) if user else None
session.close() session.close()