summaryrefslogtreecommitdiff
path: root/users/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2012-12-20 01:53:32 -0800
committerazul <azul@riseup.net>2012-12-20 01:53:32 -0800
commit69a6c34998328b2168053184e1e487b60e1cc536 (patch)
tree361b0be19535b0d7ddb3eaac7acdfcebc7a0e3a8 /users/app/controllers/users_controller.rb
parente899e5c3f33acb3228fac295013d7cc8b6e4eb04 (diff)
parentdc827d0a80360aa245d4d724dc42bc47571faea6 (diff)
Merge pull request #5 from leapcode/feature/removing-email-aliases
Removing email aliases - proper error display
Diffstat (limited to 'users/app/controllers/users_controller.rb')
-rw-r--r--users/app/controllers/users_controller.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 811e8e5..3d71c1a 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -3,6 +3,7 @@ class UsersController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:create]
before_filter :fetch_user, :only => [:edit, :update, :destroy]
+ before_filter :set_anchor, :only => [:edit, :update]
before_filter :authorize_admin, :only => [:index]
respond_to :json, :html
@@ -27,16 +28,16 @@ class UsersController < ApplicationController
end
def edit
+ @email_alias = LocalEmail.new
end
def update
@user.attributes = params[:user]
+ @email_alias = @user.email_aliases.last
if @user.changed? and @user.save
flash[:notice] = t(:user_updated_successfully)
- else
- flash[:error] = @user.errors.full_messages
end
- respond_with @user, :location => edit_user_path(@user)
+ respond_with @user, :location => edit_user_path(@user, :anchor => :email)
end
def destroy
@@ -50,4 +51,13 @@ class UsersController < ApplicationController
@user = User.find_by_param(params[:id])
access_denied unless admin? or (@user == current_user)
end
+
+ def set_anchor
+ @anchor = email_settings? ? :email : :account
+ end
+
+ def email_settings?
+ params[:user] &&
+ params[:user].keys.detect{|key| key.index('email')}
+ end
end