mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 07:49:50 -05:00
Allow database creation without password
* The warning about not having a password is now properly shown (previously it did not let you continue at all) * General cleanup of the master key editing workflow
This commit is contained in:
parent
e20d652cca
commit
37b18a532c
@ -136,34 +136,34 @@ bool DatabaseSettingsWidgetMasterKey::save()
|
||||
|
||||
auto newKey = QSharedPointer<CompositeKey>::create();
|
||||
|
||||
QSharedPointer<Key> passwordKey;
|
||||
QSharedPointer<Key> fileKey;
|
||||
QSharedPointer<ChallengeResponseKey> ykCrKey;
|
||||
QSharedPointer<Key> oldPasswordKey;
|
||||
QSharedPointer<Key> oldFileKey;
|
||||
QSharedPointer<ChallengeResponseKey> oldChallengeResponse;
|
||||
|
||||
for (const auto& key : m_db->key()->keys()) {
|
||||
if (key->uuid() == PasswordKey::UUID) {
|
||||
passwordKey = key;
|
||||
oldPasswordKey = key;
|
||||
} else if (key->uuid() == FileKey::UUID) {
|
||||
fileKey = key;
|
||||
oldFileKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& key : m_db->key()->challengeResponseKeys()) {
|
||||
if (key->uuid() == YkChallengeResponseKey::UUID) {
|
||||
ykCrKey = key;
|
||||
oldChallengeResponse = key;
|
||||
}
|
||||
}
|
||||
|
||||
if (!addToCompositeKey(m_passwordEditWidget, newKey, passwordKey)) {
|
||||
if (!addToCompositeKey(m_passwordEditWidget, newKey, oldPasswordKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!addToCompositeKey(m_keyFileEditWidget, newKey, fileKey)) {
|
||||
if (!addToCompositeKey(m_keyFileEditWidget, newKey, oldFileKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef WITH_XC_YUBIKEY
|
||||
if (!addToCompositeKey(m_yubiKeyEditWidget, newKey, ykCrKey)) {
|
||||
if (!addToCompositeKey(m_yubiKeyEditWidget, newKey, oldChallengeResponse)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -177,7 +177,7 @@ bool DatabaseSettingsWidgetMasterKey::save()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_passwordEditWidget->visiblePage() == KeyComponentWidget::AddNew) {
|
||||
if (m_passwordEditWidget->isEmpty()) {
|
||||
auto answer = MessageBox::warning(this,
|
||||
tr("No password set"),
|
||||
tr("WARNING! You have not set a password. Using a database without "
|
||||
|
@ -40,7 +40,10 @@ PasswordEditWidget::~PasswordEditWidget()
|
||||
|
||||
bool PasswordEditWidget::addToCompositeKey(QSharedPointer<CompositeKey> key)
|
||||
{
|
||||
key->addKey(QSharedPointer<PasswordKey>::create(m_compUi->enterPasswordEdit->text()));
|
||||
QString pw = m_compUi->enterPasswordEdit->text();
|
||||
if (!pw.isEmpty()) {
|
||||
key->addKey(QSharedPointer<PasswordKey>::create(pw));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,6 +63,11 @@ bool PasswordEditWidget::isPasswordVisible() const
|
||||
return m_compUi->togglePasswordButton->isChecked();
|
||||
}
|
||||
|
||||
bool PasswordEditWidget::isEmpty() const
|
||||
{
|
||||
return m_compUi->enterPasswordEdit->text().isEmpty();
|
||||
}
|
||||
|
||||
QWidget* PasswordEditWidget::componentEditWidget()
|
||||
{
|
||||
m_compEditWidget = new QWidget();
|
||||
@ -86,11 +94,6 @@ void PasswordEditWidget::initComponentEditWidget(QWidget* widget)
|
||||
|
||||
bool PasswordEditWidget::validate(QString& errorMessage) const
|
||||
{
|
||||
if (m_compUi->enterPasswordEdit->text().isEmpty()) {
|
||||
errorMessage = tr("Password cannot be empty.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_compUi->enterPasswordEdit->text() != m_compUi->repeatPasswordEdit->text()) {
|
||||
errorMessage = tr("Passwords do not match.");
|
||||
return false;
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
bool addToCompositeKey(QSharedPointer<CompositeKey> key) override;
|
||||
void setPasswordVisible(bool visible);
|
||||
bool isPasswordVisible() const;
|
||||
bool isEmpty() const;
|
||||
bool validate(QString& errorMessage) const override;
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user