Author: Braulio Bhavamitra <braulio@prout.io>
stores_app: serialize user
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/plugins/stores_app/app/controllers/profile/stores_app_plugin/users_controller.rb b/plugins/stores_app/app/controllers/profile/stores_app_plugin/users_controller.rb index 154ded879be3de81158943241d66def64e47a815..fb4d03ba2ff7fa11304e5c21c0c4a73a9da3d269 100644 --- a/plugins/stores_app/app/controllers/profile/stores_app_plugin/users_controller.rb +++ b/plugins/stores_app/app/controllers/profile/stores_app_plugin/users_controller.rb @@ -4,7 +4,7 @@ def signin @user = User.authenticate params[:login], params[:password] if @user - render json: {auth_token: @user.private_token} + render json: UserSerializer.new(@user).to_hash else render json: {error: 'invalid_login_pass'} end diff --git a/plugins/stores_app/app/serializers/stores_app_plugin/user_serializer.rb b/plugins/stores_app/app/serializers/stores_app_plugin/user_serializer.rb new file mode 100644 index 0000000000000000000000000000000000000000..fa99558f64217f337d09f77da41b0bf00ab1f7c1 --- /dev/null +++ b/plugins/stores_app/app/serializers/stores_app_plugin/user_serializer.rb @@ -0,0 +1,20 @@ +module StoresAppPlugin + class UserSerializer < ApplicationSerializer + + alias_method :user, :object + + attribute :name + attribute :email + attribute :phone + attribute :auth_token + + def name + user.person.name + end + + def auth_token + user.private_token + end + + end +end