From 42671b4b5f38064faba02c6e220c425f39afd87c Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 23 Feb 2023 17:30:00 -0600 Subject: AƱade login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/authentications_controller.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'app/controllers/api/authentications_controller.rb') diff --git a/app/controllers/api/authentications_controller.rb b/app/controllers/api/authentications_controller.rb index 90f04d8..f2fb993 100644 --- a/app/controllers/api/authentications_controller.rb +++ b/app/controllers/api/authentications_controller.rb @@ -3,7 +3,16 @@ module Api # The controller that handles authentications. class AuthenticationsController < ApplicationController - def create; end + AUTHENTICATION_ERROR = 'Credenciales incorrectas' + + def create + @logic = logic + @token = @logic.call + + render json: @token && return if @token + + render json: { message: AUTHENTICATION_ERROR}, status: :unauthorized + end def destroy; end @@ -14,5 +23,9 @@ module Api def permitted_params params.require(:user_account).permit(:email, :password) end + + def service + @service = Services::AuthenticationService.new(permitted_params) + end end -end \ No newline at end of file +end -- cgit v1.2.3