diff options
author | Azul <azul@leap.se> | 2012-12-09 10:52:23 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-09 10:52:23 +0100 |
commit | 4dffda05477f74c90197948bb6f13bedc8b2a19f (patch) | |
tree | d78706cb5d6a49d8919c1dbcf340d436257956e4 /users/app/controllers | |
parent | 5cfabde4f04d9212af5efee805479bd1be3c5cf1 (diff) |
first steps towards email aliases
* unit tests draft
* controller draft
Diffstat (limited to 'users/app/controllers')
-rw-r--r-- | users/app/controllers/email_alias_controller.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/users/app/controllers/email_alias_controller.rb b/users/app/controllers/email_alias_controller.rb new file mode 100644 index 0000000..979c8ad --- /dev/null +++ b/users/app/controllers/email_alias_controller.rb @@ -0,0 +1,36 @@ +class EmailAliasesController < ApplicationController + + before_filter :fetch_user + + # 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 + 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 + end + + def destroy + @alias = @user.get_email_alias(params[:id]) + flash[:notice] = t(:email_alias_destroyed_successfully) + @alias.destroy + end + + protected + + def fetch_user + @user = User.find_by_param(params[:user_id]) + access_denied unless admin? or (@user == current_user) + end +end |