[users] Add password fields to Config

- no checking is done for validity, and there is no password-status
This commit is contained in:
Adriaan de Groot 2020-08-05 13:29:06 +02:00
parent b2b9ae7799
commit eb72d662d1
2 changed files with 65 additions and 1 deletions

View File

@ -381,7 +381,7 @@ Config::setRequireStrongPasswords( bool strong )
} }
bool bool
Config::isPasswordAcceptable(const QString& password, QString& message) Config::isPasswordAcceptable( const QString& password, QString& message )
{ {
bool failureIsFatal = requireStrongPasswords(); bool failureIsFatal = requireStrongPasswords();
@ -399,7 +399,43 @@ Config::isPasswordAcceptable(const QString& password, QString& message)
return true; return true;
} }
void
Config::setUserPassword( const QString& s )
{
m_userPassword = s;
// TODO: check new password status
emit userPasswordChanged( s );
}
void
Config::setUserPasswordSecondary( const QString& s )
{
m_userPasswordSecondary = s;
// TODO: check new password status
emit userPasswordSecondaryChanged( s );
}
void
Config::setRootPassword( const QString& s )
{
if ( writeRootPassword() )
{
m_rootPassword = s;
// TODO: check new password status
emit rootPasswordChanged( s );
}
}
void
Config::setRootPasswordSecondary( const QString& s )
{
if ( writeRootPassword() )
{
m_rootPasswordSecondary = s;
// TODO: check new password status
emit rootPasswordSecondaryChanged( s );
}
}
STATICTEST void STATICTEST void

View File

@ -59,6 +59,13 @@ class Config : public QObject
Q_PROPERTY( QString hostNameStatus READ hostNameStatus NOTIFY hostNameStatusChanged ) Q_PROPERTY( QString hostNameStatus READ hostNameStatus NOTIFY hostNameStatusChanged )
Q_PROPERTY( HostNameActions hostNameActions READ hostNameActions CONSTANT ) Q_PROPERTY( HostNameActions hostNameActions READ hostNameActions CONSTANT )
Q_PROPERTY( QString userPassword READ userPassword WRITE setUserPassword NOTIFY userPasswordChanged )
Q_PROPERTY( QString userPasswordSecondary READ userPasswordSecondary WRITE setUserPasswordSecondary NOTIFY
userPasswordSecondaryChanged )
Q_PROPERTY( QString rootPassword READ rootPassword WRITE setRootPassword NOTIFY rootPasswordChanged )
Q_PROPERTY( QString rootPasswordSecondary READ rootPasswordSecondary WRITE setRootPasswordSecondary NOTIFY
rootPasswordSecondaryChanged )
Q_PROPERTY( bool writeRootPassword READ writeRootPassword CONSTANT ) Q_PROPERTY( bool writeRootPassword READ writeRootPassword CONSTANT )
Q_PROPERTY( bool reuseUserPasswordForRoot READ reuseUserPasswordForRoot WRITE setReuseUserPasswordForRoot NOTIFY Q_PROPERTY( bool reuseUserPasswordForRoot READ reuseUserPasswordForRoot WRITE setReuseUserPasswordForRoot NOTIFY
reuseUserPasswordForRootChanged ) reuseUserPasswordForRootChanged )
@ -123,6 +130,11 @@ public:
*/ */
bool isPasswordAcceptable( const QString& password, QString& message ); bool isPasswordAcceptable( const QString& password, QString& message );
QString userPassword() const { return m_userPassword; }
QString userPasswordSecondary() const { return m_userPasswordSecondary; }
QString rootPassword() const { return m_rootPassword; }
QString rootPasswordSecondary() const { return m_rootPasswordSecondary; }
static const QStringList& forbiddenLoginNames(); static const QStringList& forbiddenLoginNames();
static const QStringList& forbiddenHostNames(); static const QStringList& forbiddenHostNames();
@ -158,6 +170,11 @@ public Q_SLOTS:
/// Change setting for "require strong password" /// Change setting for "require strong password"
void setRequireStrongPasswords( bool strong ); void setRequireStrongPasswords( bool strong );
void setUserPassword( const QString& );
void setUserPasswordSecondary( const QString& );
void setRootPassword( const QString& );
void setRootPasswordSecondary( const QString& );
signals: signals:
void userShellChanged( const QString& ); void userShellChanged( const QString& );
void autologinGroupChanged( const QString& ); void autologinGroupChanged( const QString& );
@ -170,6 +187,11 @@ signals:
void autoLoginChanged( bool ); void autoLoginChanged( bool );
void reuseUserPasswordForRootChanged( bool ); void reuseUserPasswordForRootChanged( bool );
void requireStrongPasswordsChanged( bool ); void requireStrongPasswordsChanged( bool );
void userPasswordChanged( const QString& );
void userPasswordSecondaryChanged( const QString& );
void rootPasswordChanged( const QString& );
void rootPasswordSecondaryChanged( const QString& );
private: private:
QStringList m_defaultGroups; QStringList m_defaultGroups;
@ -179,6 +201,12 @@ private:
QString m_fullName; QString m_fullName;
QString m_loginName; QString m_loginName;
QString m_hostName; QString m_hostName;
QString m_userPassword;
QString m_userPasswordSecondary; // enter again to be sure
QString m_rootPassword;
QString m_rootPasswordSecondary;
bool m_doAutoLogin = false; bool m_doAutoLogin = false;
bool m_writeRootPassword = true; bool m_writeRootPassword = true;