diff options
author | azul <azul@riseup.net> | 2013-07-06 07:51:54 -0700 |
---|---|---|
committer | azul <azul@riseup.net> | 2013-07-06 07:51:54 -0700 |
commit | a18efa42ddc1cf8692d55f76ca3e92792913f40d (patch) | |
tree | 00527737a38bdafcd2e175bb6caf5e30b3360de1 /users/app/controllers/email_settings_controller.rb | |
parent | d03e82b4df5075f796f56fb9568992b0ba0d7c07 (diff) | |
parent | dc98ad8c6445182d60b3f1909e0260ace6fbfca5 (diff) |
Merge pull request #55 from elijh/feature/new-ui
Feature/new ui
Diffstat (limited to 'users/app/controllers/email_settings_controller.rb')
-rw-r--r-- | users/app/controllers/email_settings_controller.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/users/app/controllers/email_settings_controller.rb b/users/app/controllers/email_settings_controller.rb new file mode 100644 index 0000000..f7d85be --- /dev/null +++ b/users/app/controllers/email_settings_controller.rb @@ -0,0 +1,41 @@ +class EmailSettingsController < UsersBaseController + + before_filter :authorize + before_filter :fetch_user + + def edit + @email_alias = LocalEmail.new + end + + def update + @user.attributes = cleanup_params(params[:user]) + if @user.changed? + if @user.save + flash[:notice] = t(:changes_saved) + redirect + else + if @user.email_aliases.last && !@user.email_aliases.last.valid? + # display bad alias in text field: + @email_alias = @user.email_aliases.pop + end + render 'email_settings/edit' + end + else + redirect + end + end + + private + + def redirect + redirect_to edit_user_email_settings_url(@user) + end + + def cleanup_params(user) + if !user['email_forward'].nil? && user['email_forward'].empty? + user.delete('email_forward') # don't allow "" as an email forward + end + user + end + +end |