mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-27 01:15:38 -04:00
[users] Use libpwquality for additional password checks
- add cmake module to find libpwquality - move checking functions to their own file - some Transifex hackery - stub out the libpwquality check
This commit is contained in:
parent
9a9c6da6db
commit
27e1de6548
6 changed files with 242 additions and 90 deletions
|
@ -26,9 +26,9 @@
|
|||
|
||||
#include "Typedefs.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include "CheckPWQuality.h"
|
||||
|
||||
#include <functional>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -70,41 +70,7 @@ signals:
|
|||
private:
|
||||
Ui::Page_UserSetup* ui;
|
||||
|
||||
/**
|
||||
* Support for (dynamic) checks on the password's validity.
|
||||
* This can be used to implement password requirements like
|
||||
* "at least 6 characters". Function addPasswordCheck()
|
||||
* instantiates these and adds them to the list of checks.
|
||||
*/
|
||||
class PasswordCheck
|
||||
{
|
||||
public:
|
||||
/** Return true if the string is acceptable. */
|
||||
using AcceptFunc = std::function<bool( const QString& )>;
|
||||
using MessageFunc = std::function<QString()>;
|
||||
|
||||
/** Generate a @p message if @p filter returns true */
|
||||
PasswordCheck( MessageFunc message, AcceptFunc filter );
|
||||
/** Yields @p message if @p filter returns true */
|
||||
PasswordCheck( const QString& message, AcceptFunc filter );
|
||||
/** Null check, always returns empty */
|
||||
PasswordCheck();
|
||||
|
||||
/** Applies this check to the given password string @p s
|
||||
* and returns an empty string if the password is ok
|
||||
* according to this filter. Returns a message describing
|
||||
* what is wrong if not.
|
||||
*/
|
||||
QString filter( const QString& s ) const
|
||||
{
|
||||
return m_accept( s ) ? QString() : m_message();
|
||||
}
|
||||
|
||||
private:
|
||||
MessageFunc m_message;
|
||||
AcceptFunc m_accept;
|
||||
} ;
|
||||
QVector<PasswordCheck> m_passwordChecks;
|
||||
PasswordCheckList m_passwordChecks;
|
||||
|
||||
const QRegExp USERNAME_RX = QRegExp( "^[a-z_][a-z0-9_-]*[$]?$" );
|
||||
const QRegExp HOSTNAME_RX = QRegExp( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue