blob: 751df8528c6a4875efef6aab14e32cf2e6f73dcc (
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
29
30
31
32
33
34
35
36
37
38
39
|
class EmailAliasesController < ApplicationController
before_filter :fetch_user
respond_to :html
# get a list of email aliases for the given user?
def index
@aliases = @user.email_aliases
respond_with @aliases
end
def create
@alias = @user.add_email_alias(params[:email_alias])
flash[:notice] = t(:email_alias_created_successfully) unless @alias.errors
respond_with @alias, :location => edit_user_path(@user, :anchor => :email)
end
def update
@alias = @user.get_email_alias(params[:id])
@alias.set_email(params[:email_alias])
flash[:notice] = t(:email_alias_updated_successfully) unless @alias.errors
respond_with @alias, :location => edit_user_path(@user, :anchor => :email)
end
def destroy
@alias = @user.get_email_alias(params[:id])
flash[:notice] = t(:email_alias_destroyed_successfully)
@alias.destroy
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
|