Use the existing prompt
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
e80d3c2a10
commit
8d33d76ce8
3 changed files with 27 additions and 73 deletions
|
@ -22,7 +22,6 @@
|
|||
.oc-dialog-buttonrow {
|
||||
display: block;
|
||||
background: transparent;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 10px;
|
||||
|
|
|
@ -983,38 +983,3 @@ fieldset.warning legend + p, fieldset.update legend + p {
|
|||
opacity: 0;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
}
|
||||
|
||||
#sudo-login-background {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #1d2d44;
|
||||
opacity:0.4;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
#sudo-login-form {
|
||||
position: absolute;
|
||||
top: 45%;
|
||||
left: 40%;
|
||||
border: 1px solid #e9322d;
|
||||
color: #e9322d;
|
||||
font-weight: bold;
|
||||
z-index: 1000;
|
||||
background: #e4b9c0;
|
||||
border-radius: 10px;
|
||||
opacity:1;
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
#sudo-login-form .question {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
#sudo-login-form .confirm {
|
||||
position: relative;
|
||||
right: 32px;
|
||||
border: none;
|
||||
opacity: .3;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
|
|
@ -1517,31 +1517,15 @@ function initCore() {
|
|||
}
|
||||
|
||||
OC.PasswordConfirmation = {
|
||||
$form: null,
|
||||
$background: null,
|
||||
$input: null,
|
||||
$submit: null,
|
||||
callback: null,
|
||||
|
||||
init: function() {
|
||||
var self = this;
|
||||
this.$form = $('#sudo-login-form');
|
||||
this.$background = $('#sudo-login-background');
|
||||
this.$input = this.$form.find('.question');
|
||||
this.$submit = this.$form.find('.confirm');
|
||||
|
||||
this.$background.on('click', _.bind(this._fadeOut, this));
|
||||
$('.password-confirm-required').on('click', _.bind(this.requirePasswordConfirmation, this));
|
||||
this.$submit.on('click', _.bind(this._submitPasswordConfirmation, this));
|
||||
this.$input.keyup(function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
self._submitPasswordConfirmation();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
requiresPasswordConfirmation: function() {
|
||||
var timeSinceLogin = moment.now() - nc_lastLogin * 1000;
|
||||
return timeSinceLogin > 10 * 1000; // 30 minutes
|
||||
return timeSinceLogin > 30 * 60 * 1000; // 30 minutes
|
||||
},
|
||||
|
||||
|
@ -1549,50 +1533,56 @@ OC.PasswordConfirmation = {
|
|||
* @param {function} callback
|
||||
*/
|
||||
requirePasswordConfirmation: function(callback) {
|
||||
var self = this;
|
||||
|
||||
if (this.requiresPasswordConfirmation()) {
|
||||
this.$form.removeClass('hidden');
|
||||
this.$background.removeClass('hidden');
|
||||
this.$input.val('');
|
||||
OC.dialogs.prompt(
|
||||
t(
|
||||
'core',
|
||||
'This action requires you to confirm your password'
|
||||
),
|
||||
t('core','Authentication required'),
|
||||
function (result, password) {
|
||||
if (result && password !== '') {
|
||||
self._confirmPassword(password);
|
||||
}
|
||||
},
|
||||
true,
|
||||
t('core','Password'),
|
||||
true
|
||||
).then(function() {
|
||||
var $dialog = $('.oc-dialog:visible');
|
||||
$dialog.find('.ui-icon').remove();
|
||||
|
||||
var $buttons = $dialog.find('button');
|
||||
$buttons.eq(0).text(t('core', 'Cancel'));
|
||||
$buttons.eq(1).text(t('core', 'Confirm'));
|
||||
});
|
||||
}
|
||||
|
||||
this.callback = callback;
|
||||
},
|
||||
|
||||
_submitPasswordConfirmation: function() {
|
||||
_confirmPassword: function(password) {
|
||||
var self = this;
|
||||
|
||||
self.$submit.removeClass('icon-confirm').addClass('icon-loading-small');
|
||||
|
||||
$.ajax({
|
||||
url: OC.generateUrl('/login/confirm'),
|
||||
data: {
|
||||
password: this.$input.val()
|
||||
password: password
|
||||
},
|
||||
type: 'POST',
|
||||
success: function(response) {
|
||||
self.$input.val('');
|
||||
nc_lastLogin = response.lastLogin;
|
||||
self.$submit.addClass('icon-confirm').removeClass('icon-loading-small');
|
||||
|
||||
self.$form.addClass('hidden');
|
||||
self.$background.addClass('hidden');
|
||||
|
||||
if (_.isFunction(self.callback)) {
|
||||
self.callback();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
self.$input.val('');
|
||||
OC.Notification.showTemporary(t('core', 'Failed to authenticate, try again'));
|
||||
self.$submit.addClass('icon-confirm').removeClass('icon-loading-small');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_fadeOut: function() {
|
||||
this.$form.addClass('hidden');
|
||||
this.$background.addClass('hidden');
|
||||
this.$input.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue