-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enable / Disable user from web application #27333
Conversation
@AlexLaroche, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @ringmaster and @PVince81 to be potential reviewers. |
Thanks a lot! Please have a look at the failing unit tests. And also please get rid of that ajax/set enabled.php |
which means: please use the UsersController class instead. Let us know if you need help 😄 |
@AlexLaroche 13 unit tests are failing - please have a look - in case you need guidance just let us know. THX https://jenkins.owncloud.org/job/owncloud-core/job/core/job/PR-27333/2/testReport/ |
Nice! Great job! |
@AlexLaroche tests passed, great. Please let us know when you think this is ready for another review. (you might still be tweaking stuff, we can't guess 😄) |
It's ready for review. :) |
Other than that this seems to work nicely! I'll have a look at the code. |
Steps to reproduce:
Expected: 403 error |
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.
Apart from some minor issues (and the bugs), the code looks good!
$userId = $this->userSession->getUser()->getUID(); | ||
$user = $this->userManager->get($id); | ||
|
||
if($userId === $id |
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.
yes, prevent disabling yourself, but it seems this doesn't work correctly
); | ||
} | ||
|
||
if($enabled !== 'true' && $enabled !== 'false') |
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.
Maybe convert this to a boolean directly at the beginning of the function ?
Booleans compared as strings usually give me the shivers 😄
settings/js/users/users.js
Outdated
onEnabledChange: function() { | ||
var $select = $(this); | ||
var uid = UserList.getUID($select); | ||
var enabled = $select.attr('checked') ? 'true' : 'false'; |
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.
use the boolean $select.prop('checked')
for better browser compatibility
settings/js/users/users.js
Outdated
var enabled = $select.attr('checked') ? 'true' : 'false'; | ||
UserList._updateEnabled(uid, enabled, function(returnedEnabled){ | ||
if (enabled !== returnedEnabled) { | ||
$select.find('#isEnabled').attr("checked", user.isEnabled); |
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.
use $select.prop('checked', user.isEnabled)
for better browser compatibility
settings/js/users/users.js
Outdated
function (result) { | ||
if(result.status == 'success') { | ||
var msg = 'User have been ' + (result.data.enabled === 'true' ? 'enabled' : 'disabled') + '!'; | ||
OC.Notification.showTemporary(t('admin', msg)); |
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.
Please add the message directly inside the t()
block instead of using a variable.
This is because the translation bot looks for the t()
functions to find what text to submit for translation.
Also use a placeholder for the state: t('admin', 'User {displayName} has been {state}', {displayName: ..., state: stateText)
. and for the stateText: t('admin', 'enabled')
, etc
@@ -46,6 +47,9 @@ | |||
><span class="title groupsList"></span><span class="icon-triangle-s"></span></div> | |||
</td> | |||
<?php endif;?> | |||
<td class="enabled"> | |||
<input type="checkbox" id="isEnabled" checked="checked"> |
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.
Please use a class
instead of id
because ids must be unique within the page but here it would be repeated across the page. This will also require changing your jQuery selectors.
@AlexLaroche ready for review again or are you still working on it ? (please always post a message when ready for review) |
@PVince81 : In your requirements to merge the code, it still missing :
I have don't time to add it for the moment. I will try to implement it when I will have more time. |
I think the undo thing can be implemented separately. Let me rereview. |
settings/js/users/users.js
Outdated
@@ -25,8 +26,11 @@ var UserList = { | |||
initialize: function($el) { | |||
this.$el = $el; | |||
|
|||
UserList.currentUser = document.getElementsByTagName('head')[0].getAttribute('data-user'); |
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.
you can use OC.getCurrentUser().uid
which would be slightly better
I've retested and apart from these two points I think this is good to go. |
@PVince81 : All should be OK now. It was a single line of code that cause the bug. :) |
Tested, works 👍 |
Added the feature list: https://github.com/owncloud/core/wiki/ownCloud-10.0-Features |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
The option introduce permet to enable / disable to users management in the web application.
The option is available only to an admin or a subadmin.
Related Issue
#809
#12601
Motivation and Context
Easy management of the users.
How Has This Been Tested?
The functionnality have been test with the owncloud version 9.1.4.2 installed on Ubuntu 16.04.2 LTS.
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-07-14T12:32:26
PHP 7.0.15-0ubuntu0.16.04.4
Screenshots (if appropriate):
Types of changes
Checklist: