Prevent bad encrypting of folder if E2EE has not been correctly set up
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 28 Nov 2022 14:09:20 +0000 (15:09 +0100)
committerClaudio Cambra <claudio.cambra@gmail.com>
Mon, 28 Nov 2022 16:48:53 +0000 (17:48 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/accountsettings.cpp

index cf2103a7001d8ac87e0da95d7fb2a683b7d68542..2f7ed10b5a101836795ac555d0467beb47003d59 100644 (file)
@@ -321,7 +321,7 @@ void AccountSettings::doExpand()
     }
 }
 
-bool AccountSettings::canEncryptOrDecrypt (const FolderStatusModel::SubFolderInfo* info) {
+bool AccountSettings::canEncryptOrDecrypt(const FolderStatusModel::SubFolderInfo* info) {
     if (info->_folder->syncResult().status() != SyncResult::Status::Success) {
         QMessageBox msgBox;
         msgBox.setText("Please wait for the folder to sync before trying to encrypt it.");
@@ -329,6 +329,27 @@ bool AccountSettings::canEncryptOrDecrypt (const FolderStatusModel::SubFolderInf
         return false;
     }
 
+    if (!_accountState->account()->e2e() || _accountState->account()->e2e()->_mnemonic.isEmpty()) {
+        QMessageBox msgBox;
+        msgBox.setText(tr("End-to-end encryption is not configured on this device. "
+                          "Once it is configured, you will be able to encrypt this folder.\n"
+                          "Would you like to set up end-to-end encryption?"));
+        msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+        msgBox.setDefaultButton(QMessageBox::Ok);
+        const auto ret = msgBox.exec();
+
+        switch (ret) {
+        case QMessageBox::Ok:
+            slotE2eEncryptionGenerateKeys();
+            break;
+        case QMessageBox::Cancel:
+        default:
+            break;
+        }
+
+        return false;
+    }
+
     // for some reason the actual folder in disk is info->_folder->path + info->_path.
     QDir folderPath(info->_folder->path() + info->_path);
     folderPath.setFilter( QDir::AllEntries | QDir::NoDotAndDotDot );