mud_server.admin_tui.screens.login
Login screen for PipeWorks Admin TUI.
This module provides the login form where administrators enter their credentials to authenticate with the MUD server.
The LoginScreen uses Textual’s Screen class to provide a full-window login form with username and password inputs.
Classes
Login screen with username/password form. |
Module Contents
- class mud_server.admin_tui.screens.login.LoginScreen
Bases:
textual.screen.ScreenLogin screen with username/password form.
This screen displays a centered login form. On successful authentication, it posts a LoginSuccess message that the main app handles to transition to the dashboard.
- Key Bindings:
ctrl+q: Quit application
- CSS Classes:
.login-box: The container for the login form. .login-title: The “Admin Login” heading. .login-label: Labels for input fields. .login-input: The input fields. .login-button: The submit button. .login-error: Error message display.
- Messages:
LoginSuccess: Posted when login succeeds, contains username and role.
- BINDINGS
- action_quit()
Quit the application.
- CSS = Multiline-String
Show Value
""" LoginScreen { align: center middle; } .login-box { width: 60; height: auto; border: solid green; padding: 1 2; } .login-title { text-align: center; text-style: bold; color: $accent; padding-bottom: 1; } .login-label { padding-top: 1; } .login-input { margin-bottom: 1; } .login-button { width: 100%; margin-top: 1; } .login-error { color: $error; text-align: center; padding-top: 1; } .login-status { color: $text-muted; text-align: center; padding-top: 1; } """
- compose()
Create the login form layout.
The form consists of: - Title - Username input - Password input - Login button - Status/error message area
- on_mount()
Focus the username field when the screen mounts.
- on_key(event)
Handle user-configured keybindings for login actions.
If a key is configured for an action, invoke the matching action method and stop further propagation.
- async handle_login_button()
Handle the login button press.
- async handle_input_submitted(event)
Handle Enter key in input fields.
If Enter is pressed in the username field, move to password. If Enter is pressed in the password field, attempt login.