Authentication UI Components Module.
The imtauthgui module provides Qt-based user interface components for authentication and authorization, including login screens, user management interfaces, role editors, and account settings dialogs.
Overview
This module provides ready-to-use UI components for authentication:
- Login and registration screens
- User account information editors
- Contact and address editors
- Role and permission management UI
- Server connection configuration dialogs
- Account menu and profile widgets
- User administration interfaces
- QML-based observers for administration
Architecture
Design Patterns
Model-View-Controller (MVC):
- Controllers handle user interactions
- Models provide data binding to auth domain
- Views render UI elements (Qt Widgets/Designer)
- Clean separation of concerns
Observer Pattern:
- QML observers for reactive UI updates
- Administration observers monitor auth events
- Change notification from domain models
- Real-time UI synchronization
Delegate Pattern:
- View delegates for custom item rendering
- Account info view delegates
- Contact info view delegates
- Consistent data presentation
Component Pattern (ACF):
- All UI components are ACF components
- Dependency injection for services
- Designer-based UI composition
- Reusable widget library
Core Components
The module provides authentication UI components:
Login Components:
CStandardLoginGuiComp (iqtgui::TDesignerGuiCompBase)
├─ User/password login form
├─ Superuser password entry
├─ Connection status display
├─ Wait indicator for async operations
└─ Login log message display
│
└─ CRemoteStandardLoginGuiComp
├─ Remote authentication via GraphQL
├─ Server connection configuration
└─ Network error handling
Account Management:
├─ Edit user account details
├─ Name, email, password fields
├─ Account status and permissions
└─ Data validation and persistence
│
├─ CAccountInfoViewDelegateComp - View delegate for accounts
└─ CStandardAccountMenuComp - Account menu widget
Contact Information:
├─ Edit contact details
├─ Phone, email, social media
├─ Multiple contact methods
└─ Validation and formatting
│
└─ CContactInfoViewDelegateComp - View delegate for contacts
Address Management:
├─ Street, city, postal code fields
├─ Country and region selection
├─ Address validation
└─ Google Maps integration
Server Configuration:
├─ Edit server connection settings
├─ Host, port, protocol configuration
├─ SSL/TLS settings
└─ Connection testing
Administration Interfaces:
CAdministrationObserverQmlComp
├─ QML-based administration observer
├─ Real-time admin event monitoring
├─ User action notifications
└─ System status display
Usage Examples
Login Screen Setup
Standard Login Screen:**
auto loginGui = CStandardLoginGuiComp::CreateInstance();
auto loginService = CLoginServiceComp::CreateInstance();
loginGui->SetAttribute("Login", loginService.get());
auto superuserProvider = CSuperuserProviderComp::CreateInstance();
loginGui->SetAttribute("SuperuserProvider", superuserProvider.get());
auto connectionStatus = CConnectionStatusProviderComp::CreateInstance();
loginGui->SetAttribute("ConnectionStatusProvider", connectionStatus.get());
loginGui->Show();
connect(loginGui, &CStandardLoginGuiComp::LoginSuccessful,
this, &MyApp::OnLoginSuccess);
Remote Login
Remote Login with GraphQL:**
auto loginGui = CRemoteStandardLoginGuiComp::CreateInstance();
auto serverConnection = CServerConnectionInterfaceParamComp::CreateInstance();
serverConnection->SetHost("auth.example.com");
serverConnection->SetHttpPort(443);
serverConnection->SetConnectionFlags(
loginGui->SetAttribute("ServerConnection", serverConnection.get());
auto remoteLogin = CRemoteLoginServiceComp::CreateInstance();
loginGui->SetAttribute("Login", remoteLogin.get());
loginGui->Show();
@ CF_SECURE
Secure connection with SSL/TLS encryption (HTTPS, WSS)
Account Editor Dialog
Edit User Account:**
auto accountEditor = CAccountInfoEditorComp::CreateInstance();
auto userCollection = GetUserCollection();
auto userId = GetCurrentUserId();
auto userInfo = userCollection->GetObject(userId);
accountEditor->SetAccountInfo(userInfo.get());
if (accountEditor->ShowDialog() == QDialog::Accepted) {
userCollection->UpdateObject(userInfo.get());
qDebug() << "Account updated successfully";
}
Contact Editor
Edit Contact Information:**
auto contactEditor = CContactInfoEditorComp::CreateInstance();
auto contactInfo = userInfo->GetContactInfo();
contactEditor->SetContactInfo(contactInfo.get());
contactEditor->EnableEmailEditing(true);
contactEditor->EnablePhoneEditing(true);
contactEditor->EnableSocialMediaEditing(true);
if (contactEditor->ShowDialog() == QDialog::Accepted) {
userInfo->SetContactInfo(contactInfo.get());
SaveUserInfo(userInfo.get());
}
Address Editor
Edit User Address:**
auto addressEditor = CAddressEditorComp::CreateInstance();
auto address = userInfo->GetAddress();
addressEditor->SetAddress(address.get());
addressEditor->EnablePostalCodeValidation(true);
addressEditor->EnableCountrySelection(true);
if (addressEditor->ShowDialog() == QDialog::Accepted) {
userInfo->SetAddress(address.get());
SaveUserInfo(userInfo.get());
}
Server Configuration Dialog
Configure Server Connection:**
auto serverEditor = CServerConnectionEditorComp::CreateInstance();
auto serverConnection = LoadServerConnectionSettings();
serverEditor->SetServerConnection(serverConnection.get());
if (serverEditor->ShowDialog() == QDialog::Accepted) {
if (serverEditor->TestConnection()) {
SaveServerConnectionSettings(serverConnection.get());
qDebug() << "Server connection configured successfully";
} else {
QMessageBox::warning(nullptr, "Connection Failed",
"Failed to connect to server with provided settings");
}
}
Account Menu Widget
User Account Menu:**
auto accountMenu = CStandardAccountMenuComp::CreateInstance();
auto currentUser = GetCurrentUserInfo();
accountMenu->SetUserInfo(currentUser.get());
ui->toolBar->addWidget(accountMenu->GetWidget());
connect(accountMenu, &CStandardAccountMenuComp::EditProfileRequested,
this, &MyApp::OnEditProfile);
connect(accountMenu, &CStandardAccountMenuComp::LogoutRequested,
this, &MyApp::OnLogout);
connect(accountMenu, &CStandardAccountMenuComp::SettingsRequested,
this, &MyApp::OnShowSettings);
Integration Patterns
MVC Integration
Pattern: User Management UI:**
class CUserManagementWidgetComp : public ACF_COMPONENT(IUserManagementWidget)
{
I_REFERENCE(IObjectCollection, m_userCollection)
QTableView* m_usersTable;
QPushButton* m_addButton;
QPushButton* m_editButton;
QPushButton* m_deleteButton;
IAccountInfoEditorComp* m_accountEditor;
public:
void InitializeUI()
{
m_usersTable = new QTableView();
auto model = new QStandardItemModel();
LoadUsersIntoModel(model);
m_usersTable->setModel(model);
m_addButton = new QPushButton("Add User");
m_editButton = new QPushButton("Edit User");
m_deleteButton = new QPushButton("Delete User");
connect(m_addButton, &QPushButton::clicked,
this, &CUserManagementWidgetComp::OnAddUser);
connect(m_editButton, &QPushButton::clicked,
this, &CUserManagementWidgetComp::OnEditUser);
connect(m_deleteButton, &QPushButton::clicked,
this, &CUserManagementWidgetComp::OnDeleteUser);
m_accountEditor = CAccountInfoEditorComp::CreateInstance();
}
void OnAddUser()
{
auto newUser = CUserInfo::CreateInstance();
m_accountEditor->SetAccountInfo(newUser.get());
if (m_accountEditor->ShowDialog() == QDialog::Accepted) {
m_userCollection->AddObject(newUser.get());
RefreshUsersTable();
}
}
void OnEditUser()
{
QModelIndex index = m_usersTable->currentIndex();
if (!index.isValid()) return;
QByteArray userId = GetUserIdFromIndex(index);
auto userInfo = m_userCollection->GetObject(userId);
m_accountEditor->SetAccountInfo(userInfo.get());
if (m_accountEditor->ShowDialog() == QDialog::Accepted) {
m_userCollection->UpdateObject(userInfo.get());
RefreshUsersTable();
}
}
void OnDeleteUser()
{
auto reply = QMessageBox::question(nullptr, "Confirm Delete",
"Are you sure you want to delete this user?",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
QModelIndex index = m_usersTable->currentIndex();
QByteArray userId = GetUserIdFromIndex(index);
m_userCollection->DeleteObject(userId);
RefreshUsersTable();
}
}
};
QML Integration
Pattern: QML Administration Observer:**
auto adminObserver = CAdministrationObserverQmlComp::CreateInstance();
adminObserver->SetAttribute("UserCollection", userCollection.get());
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("adminObserver",
adminObserver->GetQmlObject());
engine.load(QUrl("qrc:/qml/AdministrationPanel.qml"));
QML Usage:**
// AdministrationPanel.qml
import QtQuick 2.15
import QtQuick.Controls 2.15
Item {
ListView {
model: adminObserver.userListModel
delegate: ItemDelegate {
text: model.userName
onClicked: adminObserver.selectUser(model.userId)
}
}
Connections {
target: adminObserver
function onUserAdded(userId, userName) {
console.log("User added:", userName)
}
function onUserModified(userId, userName) {
console.log("User modified:", userName)
}
function onUserDeleted(userId) {
console.log("User deleted:", userId)
}
}
}
Best Practices
Input Validation
- Validate email addresses before submission
- Check password strength requirements
- Validate phone number formats
- Sanitize all user input
- Provide real-time validation feedback
- Use Qt validators where appropriate
Security in UI
- Mask password input fields
- Clear sensitive data from UI on logout
- Implement session timeout with warning
- Disable auto-complete for passwords
- Show security indicators (HTTPS lock)
- Log all authentication attempts
User Experience
- Provide clear error messages
- Show loading indicators for async operations
- Implement keyboard shortcuts
- Support tab navigation between fields
- Remember last used username (not password)
- Provide "Forgot Password?" functionality
Integration with Other Modules
With imtauth (Core Authentication):
- UI for authentication domain objects
- User, role, permission management
- Login and session handling
With imtauthgql (GraphQL API):
- Remote authentication UI
- GraphQL-based data operations
- Real-time subscriptions
With imtcom (Server Communication):
- Server connection configuration UI
- Connection status display
- Network error handling
With imtgui (Core GUI):
- Base widget components
- Designer-based UI composition
- Common UI patterns
References
Related Modules:
- imtauth - Core authentication domain
- imtauthgql - GraphQL API layer
- imtgui - Core GUI components
- imtcom - Server communication
ACF Interfaces:
- iqtgui::TDesignerGuiCompBase - Designer UI base
- iauth::ILogin - Login service interface
External Documentation: