Make sure enforced passwords are properly respected
authorRoeland Jago Douma <rullzer@owncloud.com>
Thu, 29 Oct 2015 12:31:36 +0000 (13:31 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Thu, 29 Oct 2015 14:42:25 +0000 (15:42 +0100)
Fixes for old and new servers

src/gui/ocssharejob.cpp
src/gui/share.cpp
src/gui/sharedialog.cpp

index daf90f60343bf18b7ede4cb72a56744391a65b44..f5a871bb4c7d602bfee3a5e51b32ddb547ac5903 100644 (file)
@@ -91,7 +91,7 @@ void OcsShareJob::createShare(const QString &path, ShareType shareType, const QS
     addParam(QString::fromLatin1("shareType"), QString::number(static_cast<int>(shareType)));
 
     if (!password.isEmpty()) {
-        addParam(QString::fromLatin1("shareType"), password);
+        addParam(QString::fromLatin1("password"), password);
     }
 
     if (date.isValid()) {
index abce0be52bf1cdb803350d5a5c14445b6661e534..ce897694530cb10b0d93fb4a0b9354fdedddaf66 100644 (file)
@@ -194,6 +194,7 @@ void ShareManager::slotLinkShareCreated(const QVariantMap &reply)
      */
     if (code == 403) {
         emit linkShareRequiresPassword();
+        return;
     } else if (code != 100) {
         //emit error
     }
index 54abbeecc7318523ae278937e7120c85d7784013..615ee44004c35ce562ca10fe4fbe70d89435f910 100644 (file)
@@ -223,20 +223,18 @@ void ShareDialog::slotPasswordChanged(const QString& newText)
 
 void ShareDialog::setPassword(const QString &password)
 {
-    if( _passwordJobRunning ) {
-        // This happens because the entry field and the button both trigger this slot.
-        return;
-    }
     _pi_link->startAnimation();
     _pi_password->startAnimation();
-    QString path;
+
+    _ui->checkBox_password->setEnabled(false);
+    _ui->lineEdit_password->setEnabled(false);
 
     if( !_share.isNull() ) {
         _share->setPassword(password);
     } else {
+        _ui->checkBox_shareLink->setEnabled(false);
         _manager->createLinkShare(_sharePath, password);
     }
-    _passwordJobRunning = true;
 }
 
 void ShareDialog::slotPasswordSet()
@@ -248,7 +246,6 @@ void ShareDialog::slotPasswordSet()
      */
     getShares();
 
-    _passwordJobRunning = false;
     _pi_password->stopAnimation();
 }
 
@@ -281,7 +278,9 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
             _ui->widget_shareLink->show();
             _ui->checkBox_shareLink->setChecked(true);
 
+            _ui->checkBox_password->setEnabled(true);
             if (_share->isPasswordSet()) {
+                _ui->lineEdit_password->setEnabled(true);
                 _ui->checkBox_password->setChecked(true);
                 _ui->lineEdit_password->setPlaceholderText("********");
                 _ui->lineEdit_password->show();
@@ -293,6 +292,7 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
                 _ui->pushButton_setPassword->hide();
             }
 
+            _ui->checkBox_expire->setEnabled(true);
             if (_share->getExpireDate().isValid()) {
                 _ui->calendar->setDate(_share->getExpireDate());
                 _ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
@@ -307,8 +307,13 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
              * Only directories can have public upload set
              * For public links the server sets CREATE and UPDATE permissions.
              */
-            if (!_isFile && _share->getPublicUpload()) {
-                _ui->checkBox_editing->setChecked(true);
+            if (!_isFile) {
+                _ui->checkBox_editing->setEnabled(true);
+                if (_share->getPublicUpload()) {
+                    _ui->checkBox_editing->setChecked(true);
+                } else {
+                    _ui->checkBox_editing->setChecked(false);
+                }
             }
 
             setShareLink(_share->getLink().toString());
@@ -410,6 +415,8 @@ void ShareDialog::slotCheckBoxShareLinkClicked()
             _ui->checkBox_password->setChecked(true);
             _ui->checkBox_password->setEnabled(false);
             _ui->checkBox_password->setText(tr("Public sh&aring requires a password"));
+            _ui->checkBox_expire->setEnabled(false);
+            _ui->checkBox_editing->setEnabled(false);
             _ui->lineEdit_password->setFocus();
             _ui->pushButton_copy->hide();
             _ui->widget_shareLink->show();
@@ -418,19 +425,29 @@ void ShareDialog::slotCheckBoxShareLinkClicked()
             return;
         }
 
+        _ui->checkBox_shareLink->setEnabled(false);
         _manager->createLinkShare(_sharePath);
     } else {
-        _pi_link->startAnimation();
-        _share->deleteShare();
+
+        if (!_share.isNull()) {
+            // We have a share so delete it
+            _pi_link->startAnimation();
+            _share->deleteShare();
+        } else {
+            // No share object so we are deleting while a password is required
+            _ui->widget_shareLink->hide();
+        }
+
+        
     }
 }
 
 void ShareDialog::slotCreateShareFetched(const QSharedPointer<LinkShare> share)
 {
     _pi_link->stopAnimation();
+    _pi_password->stopAnimation();
 
     _share = share;
-    _ui->pushButton_copy->show();
     getShares();
 }
 
@@ -443,6 +460,8 @@ void ShareDialog::slotCreateShareRequiresPassword()
     _ui->lineEdit_password->setFocus();
     _ui->pushButton_copy->hide();
     _ui->widget_shareLink->show();
+    _ui->checkBox_expire->setEnabled(false);
+    _ui->checkBox_editing->setEnabled(false);
 
     slotCheckBoxPasswordClicked();
 }
@@ -455,7 +474,7 @@ void ShareDialog::slotCheckBoxPasswordClicked()
         _ui->lineEdit_password->setPlaceholderText(tr("Please Set Password"));
         _ui->lineEdit_password->setFocus();
     } else {
-        ShareDialog::setPassword(QString());
+        setPassword(QString());
         _ui->lineEdit_password->setPlaceholderText(QString());
         _pi_password->startAnimation();
         _ui->lineEdit_password->hide();