diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index ea3aa5221..69712a733 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -437,6 +437,28 @@ Config::setRootPasswordSecondary( const QString& s ) } } +QString Config::rootPassword() const +{ + if ( writeRootPassword() ) + { + if ( reuseUserPasswordForRoot() ) + return userPassword(); + return m_rootPassword; + } + return QString(); +} + +QString Config::rootPasswordSecondary() const +{ + if ( writeRootPassword() ) + { + if ( reuseUserPasswordForRoot() ) + return userPasswordSecondary(); + return m_rootPasswordSecondary; + } + return QString(); +} + STATICTEST void setConfigurationDefaultGroups( const QVariantMap& map, QStringList& defaultGroups ) diff --git a/src/modules/users/Config.h b/src/modules/users/Config.h index 5177542c2..334bfcdb3 100644 --- a/src/modules/users/Config.h +++ b/src/modules/users/Config.h @@ -130,10 +130,14 @@ public: */ bool isPasswordAcceptable( const QString& password, QString& message ); + // The user enters a password (and again in a separate UI element) QString userPassword() const { return m_userPassword; } QString userPasswordSecondary() const { return m_userPasswordSecondary; } - QString rootPassword() const { return m_rootPassword; } - QString rootPasswordSecondary() const { return m_rootPasswordSecondary; } + // The root password **may** be entered in the UI, or may be suppressed + // entirely when writeRootPassword is off, or may be equal to + // the user password when reuseUserPasswordForRoot is on. + QString rootPassword() const; + QString rootPasswordSecondary() const; static const QStringList& forbiddenLoginNames(); static const QStringList& forbiddenHostNames(); diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index aca20fd58..5a96af4e4 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -199,32 +199,6 @@ UsersPage::isReady() const return readyFields; } -QString -UsersPage::getRootPassword() const -{ - if ( m_config->writeRootPassword() ) - { - if ( ui->checkBoxReusePassword->isChecked() ) - { - return ui->textBoxUserPassword->text(); - } - else - { - return ui->textBoxRootPassword->text(); - } - } - else - { - return QString(); - } -} - -QPair< QString, QString > -UsersPage::getUserPassword() const -{ - return QPair< QString, QString >( m_config->loginName(), ui->textBoxUserPassword->text() ); -} - void UsersPage::fillGlobalStorage() const { diff --git a/src/modules/users/UsersPage.h b/src/modules/users/UsersPage.h index 2f446b563..46c4ed399 100644 --- a/src/modules/users/UsersPage.h +++ b/src/modules/users/UsersPage.h @@ -48,11 +48,6 @@ public: void onActivate(); - ///@brief Root password, depends on settings, may be empty - QString getRootPassword() const; - ///@brief User name and password - QPair< QString, QString > getUserPassword() const; - protected slots: void onFullNameTextEdited( const QString& ); void reportLoginNameStatus( const QString& ); diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp index 75c76bd21..2733539b6 100644 --- a/src/modules/users/UsersViewStep.cpp +++ b/src/modules/users/UsersViewStep.cpp @@ -132,11 +132,10 @@ UsersViewStep::onLeave() m_config->doAutoLogin(), m_config->defaultGroups() ); - auto userPW = m_widget->getUserPassword(); - j = new SetPasswordJob( userPW.first, userPW.second ); + j = new SetPasswordJob( m_config->loginName(), m_config->userPassword() ); m_jobs.append( Calamares::job_ptr( j ) ); - j = new SetPasswordJob( "root", m_widget->getRootPassword() ); + j = new SetPasswordJob( "root", m_config->rootPassword() ); m_jobs.append( Calamares::job_ptr( j ) ); // TODO: Config object should create jobs