summaryrefslogtreecommitdiff
path: root/users/app/controllers/email_aliases_controller.rb
blob: 3b0d5ac83d3e5bfcf3e3309f764d91f6a90cb4af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class EmailAliasesController < ApplicationController

  before_filter :fetch_user

  respond_to :html

  def destroy
    @alias = @user.email_aliases.delete(params[:id])
    @user.save
    flash[:notice] = t(:email_alias_destroyed_successfully, :alias => @alias)
    redirect_to edit_user_path(@user, :anchor => :email)
  end

  protected

  def fetch_user
    @user = User.find_by_param(params[:user_id])
    access_denied unless admin? or (@user == current_user)
  end
end