-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d75e35b
Introduce the UI for password confirmation
nickvergessen 827b6a6
Introduce PasswordConfirmRequired annotation
nickvergessen 28ddf3a
Require password confirmation for changing the email
nickvergessen a0d6c65
Allow to check it via the API
nickvergessen 86aa619
Require confirmation when generating backup codes
nickvergessen 68fa1e5
Require password confirmation for app password
nickvergessen 6c3f0fd
Fix error message displaying
nickvergessen cc33f86
Make sure it is a function
nickvergessen 62855c0
Require confirmation when changing the email settings
nickvergessen 145da71
Require confirmation for app config changes
nickvergessen 410e0fc
Require password confirmation when changing workflow rules
nickvergessen 2fd2e45
Require password confirmation for user management
nickvergessen 47f9574
Hide and show after updating
nickvergessen 71c4edf
use proper method call for _.bind()
MorrisJobke 3dc3887
More fixes
nickvergessen 922f51e
Update class map
nickvergessen b2d9c20
Fix unit tests
nickvergessen a7feb91
Confirm on create/delete group
nickvergessen 309b21f
Require confirmation to change the displayname
nickvergessen 05df523
Empty the password field on submission of the form
nickvergessen a53c313
Require password confirmation to change the Quota
nickvergessen 02ea134
Fix error displaying on email and add confirmation
nickvergessen bb7787a
Add the 15 seconds to the window, instead of removing
nickvergessen 80abb69
Show a little explanation above the input field
nickvergessen e80d3c2
Submit on enter
rullzer 8d33d76
Use the existing prompt
nickvergessen 8ef356a
fix displayname
MorrisJobke 3ffd9a7
Fix user management callbacks
MorrisJobke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1512,8 +1512,80 @@ function initCore() { | |
$(this).text(OC.Util.relativeModifiedDate(parseInt($(this).attr('data-timestamp'), 10))); | ||
}); | ||
}, 30 * 1000); | ||
|
||
OC.PasswordConfirmation.init(); | ||
} | ||
|
||
OC.PasswordConfirmation = { | ||
callback: null, | ||
|
||
init: function() { | ||
$('.password-confirm-required').on('click', _.bind(this.requirePasswordConfirmation, this)); | ||
}, | ||
|
||
requiresPasswordConfirmation: function() { | ||
var timeSinceLogin = moment.now() - nc_lastLogin * 1000; | ||
return timeSinceLogin > 10 * 1000; // 30 minutes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) { | ||
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; | ||
}, | ||
|
||
_confirmPassword: function(password) { | ||
var self = this; | ||
|
||
$.ajax({ | ||
url: OC.generateUrl('/login/confirm'), | ||
data: { | ||
password: password | ||
}, | ||
type: 'POST', | ||
success: function(response) { | ||
nc_lastLogin = response.lastLogin; | ||
|
||
if (_.isFunction(self.callback)) { | ||
self.callback(); | ||
} | ||
}, | ||
error: function() { | ||
OC.Notification.showTemporary(t('core', 'Failed to authenticate, try again')); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
$(document).ready(initCore); | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
lib/private/AppFramework/Middleware/Security/Exceptions/NotConfirmedException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\AppFramework\Middleware\Security\Exceptions; | ||
|
||
use OCP\AppFramework\Http; | ||
|
||
/** | ||
* Class NotConfirmedException is thrown when a resource has been requested by a | ||
* user that has not confirmed their password in the last 30 minutes. | ||
* | ||
* @package OC\AppFramework\Middleware\Security\Exceptions | ||
*/ | ||
class NotConfirmedException extends SecurityException { | ||
public function __construct() { | ||
parent::__construct('Password confirmation is required', Http::STATUS_FORBIDDEN); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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