Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password confirmation for some actions #1447

Merged
merged 28 commits into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d75e35b
Introduce the UI for password confirmation
nickvergessen Sep 19, 2016
827b6a6
Introduce PasswordConfirmRequired annotation
nickvergessen Sep 19, 2016
28ddf3a
Require password confirmation for changing the email
nickvergessen Sep 19, 2016
a0d6c65
Allow to check it via the API
nickvergessen Sep 19, 2016
86aa619
Require confirmation when generating backup codes
nickvergessen Sep 19, 2016
68fa1e5
Require password confirmation for app password
nickvergessen Sep 19, 2016
6c3f0fd
Fix error message displaying
nickvergessen Sep 19, 2016
cc33f86
Make sure it is a function
nickvergessen Sep 19, 2016
62855c0
Require confirmation when changing the email settings
nickvergessen Sep 19, 2016
145da71
Require confirmation for app config changes
nickvergessen Oct 25, 2016
410e0fc
Require password confirmation when changing workflow rules
nickvergessen Oct 25, 2016
2fd2e45
Require password confirmation for user management
nickvergessen Oct 25, 2016
47f9574
Hide and show after updating
nickvergessen Oct 25, 2016
71c4edf
use proper method call for _.bind()
MorrisJobke Oct 25, 2016
3dc3887
More fixes
nickvergessen Oct 25, 2016
922f51e
Update class map
nickvergessen Nov 2, 2016
b2d9c20
Fix unit tests
nickvergessen Nov 2, 2016
a7feb91
Confirm on create/delete group
nickvergessen Nov 3, 2016
309b21f
Require confirmation to change the displayname
nickvergessen Nov 3, 2016
05df523
Empty the password field on submission of the form
nickvergessen Nov 10, 2016
a53c313
Require password confirmation to change the Quota
nickvergessen Nov 10, 2016
02ea134
Fix error displaying on email and add confirmation
nickvergessen Nov 11, 2016
bb7787a
Add the 15 seconds to the window, instead of removing
nickvergessen Nov 11, 2016
80abb69
Show a little explanation above the input field
nickvergessen Nov 11, 2016
e80d3c2
Submit on enter
rullzer Nov 16, 2016
8d33d76
Use the existing prompt
nickvergessen Nov 17, 2016
8ef356a
fix displayname
MorrisJobke Nov 18, 2016
3ffd9a7
Fix user management callbacks
MorrisJobke Nov 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/css/jquery.ocdialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
.oc-dialog-buttonrow {
display: block;
background: transparent;
position: absolute;
right: 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jancborchardt this was required because the password field was not clickable since the button row was overlaying it. Maybe you can have a look at the design a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eeeh this will mess with other dialogs like the move dialog. 👎

Will need to check it out

bottom: 0;
padding: 10px;
Expand Down
35 changes: 0 additions & 35 deletions core/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
64 changes: 27 additions & 37 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1517,82 +1517,72 @@ 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

liar 🙈

FF reports "unreachable code after return statement" on master

return timeSinceLogin > 30 * 60 * 1000; // 30 minutes
},

/**
* @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 = '';
}
};

Expand Down