File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 66#include " settings_widget.h"
77#include " ../utils/logger.h"
88#include " ../core/alpm_wrapper.h"
9+ #include " ../core/auth_manager.h"
910#include < QMenuBar>
1011#include < QMenu>
1112#include < QAction>
@@ -19,10 +20,21 @@ MainWindow::MainWindow(QWidget* parent)
1920
2021 // Initialize ALPM before creating widgets that might need it
2122 if (!AlpmWrapper::instance ().initialize ()) {
22- QMessageBox::critical (this , " Error" ,
23+ QMessageBox::critical (this , " Error" ,
2324 " Failed to initialize package manager. Please check your system configuration." );
2425 Logger::error (" Failed to initialize ALPM in MainWindow" );
2526 }
27+
28+ // Authenticate once at startup for all privileged operations
29+ if (!AuthManager::instance ().authenticate (this )) {
30+ Logger::error (" Authentication failed or cancelled" );
31+ QMessageBox::critical (this , " Authentication Required" ,
32+ " This application requires administrator privileges to manage packages.\n "
33+ " The application will now exit." );
34+ // Schedule exit after event loop starts
35+ QMetaObject::invokeMethod (qApp, &QApplication::quit, Qt::QueuedConnection);
36+ return ;
37+ }
2638
2739 setupUi ();
2840 loadStyleSheet ();
You can’t perform that action at this time.
0 commit comments