summaryrefslogtreecommitdiff
path: root/app/controllers/identities_controller.rb
blob: 624e38a110ea732c136c123d0b16c5251582aaa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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