[users] Inline isPasswordAcceptable
- the way isPasswordAcceptable was being used was buggy, leading to test failures (now fixed) - don't expose the function, anyway: it's an implementation detail for passwordStatus() which in itself is an implementation detail for status notifications.
This commit is contained in:
parent
5f2bbd179c
commit
a16ecba2bd
@ -380,25 +380,6 @@ Config::setRequireStrongPasswords( bool strong )
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Config::isPasswordAcceptable( const QString& password, QString& message ) const
|
||||
{
|
||||
bool failureIsFatal = requireStrongPasswords();
|
||||
|
||||
for ( auto pc : m_passwordChecks )
|
||||
{
|
||||
QString s = pc.filter( password );
|
||||
|
||||
if ( !s.isEmpty() )
|
||||
{
|
||||
message = s;
|
||||
return !failureIsFatal;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Config::setUserPassword( const QString& s )
|
||||
{
|
||||
@ -429,9 +410,18 @@ Config::passwordStatus( const QString& pw1, const QString& pw2 ) const
|
||||
return qMakePair( PasswordValidity::Invalid, tr( "Your passwords do not match!" ) );
|
||||
}
|
||||
|
||||
QString message;
|
||||
bool ok = isPasswordAcceptable( pw1, message );
|
||||
return qMakePair( ok ? PasswordValidity::Valid : PasswordValidity::Weak, message );
|
||||
bool failureIsFatal = requireStrongPasswords();
|
||||
for ( const auto& pc : m_passwordChecks )
|
||||
{
|
||||
QString message = pc.filter( pw1 );
|
||||
|
||||
if ( !message.isEmpty() )
|
||||
{
|
||||
return qMakePair( failureIsFatal ? PasswordValidity::Invalid : PasswordValidity::Weak, message );
|
||||
}
|
||||
}
|
||||
|
||||
return qMakePair( PasswordValidity::Valid, QString() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,17 +145,6 @@ public:
|
||||
|
||||
const QStringList& defaultGroups() const { return m_defaultGroups; }
|
||||
|
||||
/** @brief Checks if the password is acceptable.
|
||||
*
|
||||
* If all is well, sets @p message to empty and returns @c true.
|
||||
* If there are warnings, but acceptable, sets @p message to something
|
||||
* non-empty and returns @c true. This happens if requireStrongPasswords
|
||||
* is turned off (by config or user).
|
||||
* If the password is not acceptable, sets @p message to something
|
||||
* non-empty and returns @c false.
|
||||
*/
|
||||
bool isPasswordAcceptable( const QString& password, QString& message ) const;
|
||||
|
||||
// The user enters a password (and again in a separate UI element)
|
||||
QString userPassword() const { return m_userPassword; }
|
||||
QString userPasswordSecondary() const { return m_userPasswordSecondary; }
|
||||
|
Loading…
Reference in New Issue
Block a user