[users] Sort the password checks before applying them

This commit is contained in:
Adriaan de Groot 2019-11-08 13:21:37 +01:00
parent dec0cfb7d3
commit e11c9a049f
3 changed files with 10 additions and 0 deletions

View File

@ -60,6 +60,7 @@ public:
QString filter( const QString& s ) const { return m_accept( s ) ? QString() : m_message(); }
Weight weight() const { return m_weight; }
bool operator<( const PasswordCheck& other ) const { return weight() < other.weight(); }
private:
Weight m_weight;

View File

@ -424,6 +424,12 @@ UsersPage::checkPasswordAcceptance( const QString& pw1, const QString& pw2, QLab
bool failureIsFatal = ui->checkBoxValidatePassword->isChecked();
bool failureFound = false;
if ( m_passwordChecksChanged )
{
std::sort( m_passwordChecks.begin(), m_passwordChecks.end() );
m_passwordChecksChanged = false;
}
for ( auto pc : m_passwordChecks )
{
QString s = pc.filter( pw1 );
@ -502,6 +508,8 @@ UsersPage::setReusePasswordDefault( bool checked )
void
UsersPage::addPasswordCheck( const QString& key, const QVariant& value )
{
m_passwordChecksChanged = true;
if ( key == "minLength" )
{
add_check_minLength( m_passwordChecks, value );

View File

@ -90,6 +90,7 @@ private:
Ui::Page_UserSetup* ui;
PasswordCheckList m_passwordChecks;
bool m_passwordChecksChanged = false;
bool m_readyFullName;
bool m_readyUsername;