mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04: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();
|
auto newKey = QSharedPointer<CompositeKey>::create();
|
||||||
|
|
||||||
QSharedPointer<Key> passwordKey;
|
QSharedPointer<Key> oldPasswordKey;
|
||||||
QSharedPointer<Key> fileKey;
|
QSharedPointer<Key> oldFileKey;
|
||||||
QSharedPointer<ChallengeResponseKey> ykCrKey;
|
QSharedPointer<ChallengeResponseKey> oldChallengeResponse;
|
||||||
|
|
||||||
for (const auto& key : m_db->key()->keys()) {
|
for (const auto& key : m_db->key()->keys()) {
|
||||||
if (key->uuid() == PasswordKey::UUID) {
|
if (key->uuid() == PasswordKey::UUID) {
|
||||||
passwordKey = key;
|
oldPasswordKey = key;
|
||||||
} else if (key->uuid() == FileKey::UUID) {
|
} else if (key->uuid() == FileKey::UUID) {
|
||||||
fileKey = key;
|
oldFileKey = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& key : m_db->key()->challengeResponseKeys()) {
|
for (const auto& key : m_db->key()->challengeResponseKeys()) {
|
||||||
if (key->uuid() == YkChallengeResponseKey::UUID) {
|
if (key->uuid() == YkChallengeResponseKey::UUID) {
|
||||||
ykCrKey = key;
|
oldChallengeResponse = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addToCompositeKey(m_passwordEditWidget, newKey, passwordKey)) {
|
if (!addToCompositeKey(m_passwordEditWidget, newKey, oldPasswordKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addToCompositeKey(m_keyFileEditWidget, newKey, fileKey)) {
|
if (!addToCompositeKey(m_keyFileEditWidget, newKey, oldFileKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_XC_YUBIKEY
|
#ifdef WITH_XC_YUBIKEY
|
||||||
if (!addToCompositeKey(m_yubiKeyEditWidget, newKey, ykCrKey)) {
|
if (!addToCompositeKey(m_yubiKeyEditWidget, newKey, oldChallengeResponse)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -177,7 +177,7 @@ bool DatabaseSettingsWidgetMasterKey::save()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_passwordEditWidget->visiblePage() == KeyComponentWidget::AddNew) {
|
if (m_passwordEditWidget->isEmpty()) {
|
||||||
auto answer = MessageBox::warning(this,
|
auto answer = MessageBox::warning(this,
|
||||||
tr("No password set"),
|
tr("No password set"),
|
||||||
tr("WARNING! You have not set a password. Using a database without "
|
tr("WARNING! You have not set a password. Using a database without "
|
||||||
|
@ -40,7 +40,10 @@ PasswordEditWidget::~PasswordEditWidget()
|
|||||||
|
|
||||||
bool PasswordEditWidget::addToCompositeKey(QSharedPointer<CompositeKey> key)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +63,11 @@ bool PasswordEditWidget::isPasswordVisible() const
|
|||||||
return m_compUi->togglePasswordButton->isChecked();
|
return m_compUi->togglePasswordButton->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PasswordEditWidget::isEmpty() const
|
||||||
|
{
|
||||||
|
return m_compUi->enterPasswordEdit->text().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* PasswordEditWidget::componentEditWidget()
|
QWidget* PasswordEditWidget::componentEditWidget()
|
||||||
{
|
{
|
||||||
m_compEditWidget = new QWidget();
|
m_compEditWidget = new QWidget();
|
||||||
@ -86,11 +94,6 @@ void PasswordEditWidget::initComponentEditWidget(QWidget* widget)
|
|||||||
|
|
||||||
bool PasswordEditWidget::validate(QString& errorMessage) const
|
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()) {
|
if (m_compUi->enterPasswordEdit->text() != m_compUi->repeatPasswordEdit->text()) {
|
||||||
errorMessage = tr("Passwords do not match.");
|
errorMessage = tr("Passwords do not match.");
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
bool addToCompositeKey(QSharedPointer<CompositeKey> key) override;
|
bool addToCompositeKey(QSharedPointer<CompositeKey> key) override;
|
||||||
void setPasswordVisible(bool visible);
|
void setPasswordVisible(bool visible);
|
||||||
bool isPasswordVisible() const;
|
bool isPasswordVisible() const;
|
||||||
|
bool isEmpty() const;
|
||||||
bool validate(QString& errorMessage) const override;
|
bool validate(QString& errorMessage) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user