Let config suppress username field for login screen
This commit is contained in:
parent
9268d939eb
commit
069289775e
|
@ -35,12 +35,18 @@ class LoginView(WuttaView):
|
|||
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
|
||||
self.show_username = kwargs.pop('show_username', True)
|
||||
# may or may not show the username field
|
||||
# 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
|
||||
self.focused = None
|
||||
|
@ -176,7 +182,9 @@ class LoginView(WuttaView):
|
|||
|
||||
session = self.app.make_session()
|
||||
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
|
||||
session.close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue