summaryrefslogtreecommitdiff
path: root/ui/qt5/accountpage.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt5/accountpage.cc')
-rw-r--r--ui/qt5/accountpage.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/ui/qt5/accountpage.cc b/ui/qt5/accountpage.cc
index f4be6ac..bc0eb2f 100644
--- a/ui/qt5/accountpage.cc
+++ b/ui/qt5/accountpage.cc
@@ -11,12 +11,15 @@
*/
#include "accountpage.hh"
+#include "util/user.hh"
+
#ifdef HAS_INSTALL_ENV
# include "commitpage.hh"
#endif /* HAS_INSTALL_ENV */
#include <algorithm>
#include <QLabel>
+#include <QMessageBox>
#include <QVBoxLayout>
AccountPage::AccountPage(QWidget *parent) : HorizonWizardPage(parent) {
@@ -48,19 +51,35 @@ AccountPage::AccountPage(QWidget *parent) : HorizonWizardPage(parent) {
}
bool AccountPage::isComplete() const {
- return std::all_of(accountWidgets.begin(), accountWidgets.end(),
+ return std::all_of(accountWidgets.cbegin(), accountWidgets.cend(),
[](UserAccountWidget *widget) {
if(widget == nullptr) return true;
return widget->isValid();
});
}
-#ifdef HAS_INSTALL_ENV
bool AccountPage::validatePage() {
+#ifdef HAS_INSTALL_ENV
/* hack to re-initialise page in case the user goes back */
horizonWizard()->removePage(HorizonWizard::Page_Commit);
horizonWizard()->setPage(HorizonWizard::Page_Commit, new CommitPage);
+#endif /* HAS_INSTALL_ENV */
- return true;
+ return std::all_of(accountWidgets.cbegin(), accountWidgets.cend(),
+ [this](const auto &widget) {
+ auto accountText = widget->accountText();
+ if(accountText.isEmpty()) return true;
+
+ auto username = accountText.toStdString();
+ if(system_names.find(username) != system_names.end() ||
+ system_groups.find(username) != system_groups.end()) {
+ QMessageBox::critical(this, tr("Invalid Username"),
+ tr("The username you have chosen (%1) is reserved "
+ "by the system. Choose a different username.")
+ .arg(accountText));
+ return false;
+ }
+
+ return true;
+ });
}
-#endif /* HAS_INSTALL_ENV */