summaryrefslogtreecommitdiff
path: root/app/controllers/identities_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/identities_controller.rb')
-rw-r--r--app/controllers/identities_controller.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/controllers/identities_controller.rb b/app/controllers/identities_controller.rb
new file mode 100644
index 0000000..624e38a
--- /dev/null
+++ b/app/controllers/identities_controller.rb
@@ -0,0 +1,28 @@
+class IdentitiesController < ApplicationController
+
+ before_filter :require_login
+ before_filter :require_admin
+ before_filter :fetch_identity, only: :destroy
+ before_filter :protect_main_email, only: :destroy
+
+ def index
+ @identities = Identity.all
+ end
+
+ def destroy
+ @identity.destroy
+ redirect_to identities_path
+ end
+
+ protected
+ def fetch_identity
+ @identity = Identity.find(params[:id])
+ end
+
+ def protect_main_email
+ if @identity.status == :main_email
+ flash[:error] = "You cannot destroy the main email. Remove or Rename the user instead."
+ redirect_to identities_path
+ end
+ end
+end