This works fine a treat, however just 2 things :)
Firstly can you add a cucumber test for this.
Secondly, should we actually have a tick box next to current user in the list if we
can't delete it? Maybe there are other actions that can be performed, but atm it
looks as tho this box is only used for delete.
Thanks
Martyn
----- Original Message -----
From: jtomasek(a)redhat.com
To: aeolus-devel(a)lists.fedorahosted.org
Cc: "Jiri Tomasek" <jtomasek(a)redhat.com>
Sent: Monday, 4 July, 2011 1:40:08 PM
Subject: [PATCH] Admin shall not be able to delete itself
From: Jiri Tomasek <jtomasek(a)redhat.com>
This patch fixes BZ717533
---
src/app/controllers/users_controller.rb | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/app/controllers/users_controller.rb
b/src/app/controllers/users_controller.rb
index 16c514d..efebe39 100644
--- a/src/app/controllers/users_controller.rb
+++ b/src/app/controllers/users_controller.rb
@@ -113,7 +113,12 @@ class UsersController < ApplicationController
def destroy
require_privilege(Privilege::MODIFY, User)
- User.destroy(params[:id])
+ user = User.find(params[:id])
+ if user == current_user
+ flash[:warning] = "Cannot delete #{user.login}: you are logged in as this
user"
+ else
+ user.destroy
+ end
respond_to do |format|
format.html { redirect_to users_path }
--
1.7.4.2
_______________________________________________
aeolus-devel mailing list
aeolus-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/aeolus-devel