diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index e62bdebc08e2d4b407f76580b0a494b5b42b6bc0..3edffba8a3f5e4df367b145ec3b9bed9526238ec 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -762,6 +762,11 @@ class Share extends Constants {
 			$updateExistingShare = false;
 			if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
 
+				// IF the password is changed via the old ajax endpoint verify it before deleting the old share
+				if ($passwordChanged === true) {
+					self::verifyPassword($shareWith);
+				}
+
 				// when updating a link share
 				// FIXME Don't delete link if we update it
 				if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null,