Do not show passwords on user create or update.

This commit is contained in:
Martin Edenhofer 2016-05-10 16:07:39 +02:00
parent 2bdb148bce
commit 944b9bf498

View file

@ -50,7 +50,8 @@ class UsersController < ApplicationController
return return
end end
user = User.find(params[:id]) user = User.find(params[:id]).attributes_with_associations
user.delete('password')
render json: user render json: user
end end
@ -159,7 +160,8 @@ class UsersController < ApplicationController
} }
) )
end end
user_new = User.find(user.id) user_new = User.find(user.id).attributes_with_associations
user_new.delete('password')
render json: user_new, status: :created render json: user_new, status: :created
rescue => e rescue => e
render json: model_match_error(e.message), status: :unprocessable_entity render json: model_match_error(e.message), status: :unprocessable_entity
@ -206,7 +208,8 @@ class UsersController < ApplicationController
end end
# get new data # get new data
user_new = User.find( params[:id] ) user_new = User.find(params[:id]).attributes_with_associations
user_new.delete('password')
render json: user_new, status: :ok render json: user_new, status: :ok
rescue => e rescue => e
render json: { error: e.message }, status: :unprocessable_entity render json: { error: e.message }, status: :unprocessable_entity