From 6f0540d9de018f7dc9f474bdc619c8231282f19d Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sat, 25 Feb 2023 00:20:47 -0600 Subject: Arregla controlador de usuarios --- app/controllers/api/user_accounts_controller.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'app/controllers/api') diff --git a/app/controllers/api/user_accounts_controller.rb b/app/controllers/api/user_accounts_controller.rb index b95105f..3e03cf9 100644 --- a/app/controllers/api/user_accounts_controller.rb +++ b/app/controllers/api/user_accounts_controller.rb @@ -10,24 +10,17 @@ module Api end def create - @user_account = UserAccount.new(permitted_params) + @token = logic(permitted_params).call - unless @user_account.save - render json: { errors: @user_account.errors.full_messages }, status: :unprocessable_entity - return - end + render json: @token, status: :ok and return if @token - render json: Serializers::UserAccountSerializer.new(@user_account).serializable_hash + render json: { errors: @logic.user_account.errors.full_messages }, status: :unprocessable_entity end private def permitted_params - params.require(:user_account).permit(:email, :first_name, :last_name, :password) - end - - def serialized_user_account - @serialized_user_account ||= Serializers::UserAccountSerializer.new(current_user_account) + params.require(:user_account).permit(:role, :email, :first_name, :last_name, :password) end end end -- cgit v1.2.3