Skip to content

Commit

Permalink
Password policy fix and menu open on first share
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv authored and danxuliu committed Nov 1, 2018
1 parent 9dea41f commit 0a70544
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<span class="menuitem">
<form autocomplete="off" class="enforcedPassForm">
<input id="enforcedPassText" required class="enforcedPassText" type="password"
placeholder="{{passwordPlaceholder}}" autocomplete="new-password" minlength="4" />
placeholder="{{passwordPlaceholder}}" autocomplete="enforcedPassText" minlength="{{minPasswordLength}}" />
<input type="submit" value=" " class="primary icon-checkmark-white">
</form>
</span>
Expand Down
27 changes: 25 additions & 2 deletions core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,41 @@
shareData.password = this.password
}

var newShareId = false;

// We need a password before the share creation
if (isPasswordEnforced && !this.showPending && this.password === '') {
this.showPending = shareId;
this.render();
$li.find('#enforcedPassText').focus();
} else {
// else, we have a password or it is not enforced
this.model.saveLinkShare(shareData, {
$.when(this.model.saveLinkShare(shareData, {
success: function() {
$loading.addClass('hidden');
$li.find('.icon').removeClass('hidden');
self.render();
// open the menu by default
// we can only do that after the render
if (newShareId) {
var shares = self.$el.find('li[data-share-id]');
var $newShare = self.$el.find('li[data-share-id="'+newShareId+'"]');
// only open the menu by default if this is the first share
if ($newShare && shares.length === 1) {
$menu = $newShare.find('.popovermenu');
OC.showMenu(null, $menu);
}
}
},
error: function() {
OC.Notification.showTemporary(t('core', 'Unable to create a link share'));
$loading.addClass('hidden');
$li.find('.icon').removeClass('hidden');
}
})
})).then(function(response) {
// resolve before success
newShareId = response.ocs.data.id
});
}
},

Expand Down Expand Up @@ -515,6 +531,12 @@

this.$el.find('.datepicker').datepicker({dateFormat : 'dd-mm-yy'});

var minPasswordLength = 4
// password policy?
if(oc_capabilities.password_policy && oc_capabilities.password_policy.minLength) {
minPasswordLength = oc_capabilities.password_policy.minLength;
}

var popoverBase = {
social: social,
urlLabel: t('core', 'Link'),
Expand Down Expand Up @@ -550,6 +572,7 @@
isPasswordEnforced: isPasswordEnforced,
enforcedPasswordLabel: t('core', 'Password protection for links is mandatory'),
passwordPlaceholder: passwordPlaceholderInitial,
minPasswordLength: minPasswordLength,
};
var pendingPopoverMenu = this.pendingPopoverMenuTemplate(_.extend({}, pendingPopover))

Expand Down
4 changes: 3 additions & 1 deletion core/js/sharetemplates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0a70544

Please sign in to comment.