[users] Allow an explicit check for non-emptiness of passwords
- move the explicit checking for non-empty into a specific (normal) password check - leave only the-two-fields-are-equal outside of the password- requirements framework - having non-empty is the same as minLength 1, but gives a different error message
This commit is contained in:
parent
ffbc1a3e7d
commit
cc66903678
@ -407,14 +407,7 @@ UsersPage::validateHostnameText( const QString& textRef )
|
|||||||
bool
|
bool
|
||||||
UsersPage::checkPasswordAcceptance( const QString& pw1, const QString& pw2, QLabel* badge, QLabel* message )
|
UsersPage::checkPasswordAcceptance( const QString& pw1, const QString& pw2, QLabel* badge, QLabel* message )
|
||||||
{
|
{
|
||||||
if ( pw1.isEmpty() && pw2.isEmpty() )
|
if ( pw1 != pw2 )
|
||||||
{
|
|
||||||
// Not exactly labelOk() because we also don't want a checkmark OK
|
|
||||||
badge->clear();
|
|
||||||
message->clear();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if ( pw1 != pw2 )
|
|
||||||
{
|
{
|
||||||
labelError( badge, message, tr( "Your passwords do not match!" ) );
|
labelError( badge, message, tr( "Your passwords do not match!" ) );
|
||||||
return false;
|
return false;
|
||||||
@ -510,6 +503,14 @@ UsersPage::addPasswordCheck( const QString& key, const QVariant& value )
|
|||||||
{
|
{
|
||||||
add_check_maxLength( m_passwordChecks, value );
|
add_check_maxLength( m_passwordChecks, value );
|
||||||
}
|
}
|
||||||
|
else if ( key == "nonempty" )
|
||||||
|
{
|
||||||
|
if ( value.toBool() )
|
||||||
|
{
|
||||||
|
m_passwordChecks.push_back( PasswordCheck( []() { return QCoreApplication::translate( "EMP", "Password is empty" ); },
|
||||||
|
[]( const QString& s ) { return ((cDebug() << "Checking pwd" << s << "for empty"), !s.isEmpty()); } ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef CHECK_PWQUALITY
|
#ifdef CHECK_PWQUALITY
|
||||||
else if ( key == "libpwquality" )
|
else if ( key == "libpwquality" )
|
||||||
{
|
{
|
||||||
|
@ -58,8 +58,14 @@ setRootPassword: true
|
|||||||
doReusePassword: true
|
doReusePassword: true
|
||||||
|
|
||||||
# These are optional password-requirements that a distro can enforce
|
# These are optional password-requirements that a distro can enforce
|
||||||
# on the user. The values given in this sample file disable each check,
|
# on the user. The values given in this sample file set only very weak
|
||||||
# as if the check was not listed at all.
|
# validation settings.
|
||||||
|
#
|
||||||
|
# - nonempty rejects empty passwords
|
||||||
|
# - there are no length validations
|
||||||
|
# - libpwquality (if it is enabled at all) has no length of class
|
||||||
|
# restrictions, although it will still reject palindromes and
|
||||||
|
# dictionary words with these settings.
|
||||||
#
|
#
|
||||||
# Checks may be listed multiple times; each is checked separately,
|
# Checks may be listed multiple times; each is checked separately,
|
||||||
# and no effort is done to ensure that the checks are consistent
|
# and no effort is done to ensure that the checks are consistent
|
||||||
@ -84,6 +90,7 @@ doReusePassword: true
|
|||||||
# (That will show the box *Allow weak passwords* in the user-
|
# (That will show the box *Allow weak passwords* in the user-
|
||||||
# interface, and check it by default).
|
# interface, and check it by default).
|
||||||
passwordRequirements:
|
passwordRequirements:
|
||||||
|
nonempty: true
|
||||||
minLength: -1 # Password at least this many characters
|
minLength: -1 # Password at least this many characters
|
||||||
maxLength: -1 # Password at most this many characters
|
maxLength: -1 # Password at most this many characters
|
||||||
libpwquality:
|
libpwquality:
|
||||||
|
Loading…
Reference in New Issue
Block a user