Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Implemented the "Disable users" feature #240

Merged
merged 7 commits into from
Aug 3, 2015
Merged

Conversation

mssola
Copy link
Collaborator

@mssola mssola commented Jul 31, 2015

Fixes #196

current_user.admin? && User.admins.count == 1
else
# Only admin users can disable other users.
!current_user.admin?
Copy link
Member

Choose a reason for hiding this comment

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

This part of the branch is useless because we have the check_admin filter in place. So a non admin user is never going to reach this part of the code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that a regular user should be able to disable himself, therefore non-admin users should be able to perform this action. I'd say to just remove :disable from the check_admin hook (which by the way is not preventing anything, since the test in line 145 of spec/controllers/auth/registrations_controller_spec.rb passes ;) ).

Copy link
Member

Choose a reason for hiding this comment

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

Good point, ignore all my comments about this part of the code 👍

@flavio
Copy link
Member

flavio commented Jul 31, 2015

The code looks good, I have just one doubt about dropping all the team memberships

@@ -42,6 +42,11 @@ def self.find_from_event(event)
actor
end

# Returns all the enabled admins in the system.
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ActiveRecord Scopes ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! Done.

@@ -2,7 +2,8 @@ class Admin::UsersController < Admin::BaseController
respond_to :html, :js

def index
@users = User.all.page(params[:page])
@users = User.where(enabled: true).page(params[:page])
Copy link
Member

Choose a reason for hiding this comment

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

User has the enabled scope now, we should use it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

@flavio
Copy link
Member

flavio commented Aug 3, 2015

Everything looks right. I have a couple of questions though before we can merge it:

  • I see we can disable users, is there a way to enable them back? This should be done only by admings of course.
  • Is the admin able to view all the users, both disabled and enabled inside of the admin/ pages? I'm referring both to the page showing all the users registered on portus and to the team page (here it should see also the disabled members of the team)

@mssola
Copy link
Collaborator Author

mssola commented Aug 3, 2015

So, right now the feature was meant to disable the selected users, there was some discussion about enabling them back, but I think that it was dismissed (I don't recall now :/). Maybe we can add this for admins later on.

If so, then I say that we can do that in another PR (just to not complicate this PR further). I can submit the issue, and assign myself to it.

@flavio
Copy link
Member

flavio commented Aug 3, 2015

If so, then I say that we can do that in another PR (just to not complicate this PR further). I can submit the issue, and assign myself to it.

Fine, what about the other question?

@mssola
Copy link
Collaborator Author

mssola commented Aug 3, 2015

Oh yeah. Admins now are not able to see disabled users. Maybe that can be added to the proposed new issue, since listing disabled users would be annoying if anyways you cannot enable them back, no ?

@mssola mssola closed this Aug 3, 2015
@mssola mssola reopened this Aug 3, 2015
@mssola
Copy link
Collaborator Author

mssola commented Aug 3, 2015

Clicked the wrong button :_)

@flavio
Copy link
Member

flavio commented Aug 3, 2015

Oh yeah. Admins now are not able to see disabled users. Maybe that can be added to the proposed new issue, since listing disabled users would be annoying if anyways you cannot enable them back, no ?

Sounds good to me, please create the new issue

flavio added a commit that referenced this pull request Aug 3, 2015
Implemented the "Disable users" feature
@flavio flavio merged commit 2588d11 into SUSE:master Aug 3, 2015
@mssola mssola deleted the disable branch August 3, 2015 11:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants